Integrate mainline
Nick Ing-Simmons [Fri, 26 Apr 2002 17:36:16 +0000 (17:36 +0000)]
p4raw-id: //depot/perlio@16194

1  2 
embed.fnc
ext/Encode/Encode.xs

diff --cc embed.fnc
Simple merge
@@@ -140,21 -140,33 +140,33 @@@ encode_method(pTHX_ encode_t * enc, enc
                        }
                                goto ENCODE_SET_SRC;
                    }else if (check & ENCODE_PERLQQ){
 -                      SV* perlqq = 
 +                      SV* perlqq =
-                           sv_2mortal(newSVpvf("\\x{%04x}", ch));
+                           sv_2mortal(newSVpvf("\\x{%04"UVxf"}", ch));
                        sdone += slen + clen;
                        ddone += dlen + SvCUR(perlqq);
                        sv_catsv(dst, perlqq);
+                   }else if (check & ENCODE_HTMLCREF){
 -                      SV* htmlcref = 
++                      SV* htmlcref =
+                           sv_2mortal(newSVpvf("&#%" UVuf ";", ch));
+                       sdone += slen + clen;
+                       ddone += dlen + SvCUR(htmlcref);
+                       sv_catsv(dst, htmlcref);
+                   }else if (check & ENCODE_XMLCREF){
 -                      SV* xmlcref = 
++                      SV* xmlcref =
+                           sv_2mortal(newSVpvf("&#x%" UVxf ";", ch));
+                       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)",
                                enc->name[0], (U8) s[slen], code);
                        }
                        goto ENCODE_SET_SRC;
-                   }else if (check & ENCODE_PERLQQ){
 -                  }else if (check & 
++                  }else if (check &
+                             (ENCODE_PERLQQ|ENCODE_HTMLCREF|ENCODE_XMLCREF)){
 -                      SV* perlqq = 
 +                      SV* perlqq =
                            sv_2mortal(newSVpvf("\\x%02X", s[slen]));
                        sdone += slen + 1;
                        ddone += dlen + SvCUR(perlqq);