/*
- $Id: Encode.xs,v 1.43 2002/05/01 05:41:06 dankogai Exp dankogai $
+ $Id: Encode.xs,v 1.46 2002/05/20 15:25:44 dankogai Exp $
*/
#define PERL_NO_GET_CONTEXT
}
+#define ERR_ENCODE_NOMAP "\"\\x{%04" UVxf "}\" does not map to %s"
+#define ERR_DECODE_NOMAP "%s \"\\x%02" UVXf "\" does not map to Unicode"
+
static SV *
encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src,
int check)
goto ENCODE_END;
}
- while (code = do_encode(dir, s, &slen, d, dlen, &dlen, !check))
+ while( (code = do_encode(dir, s, &slen, d, dlen, &dlen, !check)) )
{
SvCUR_set(dst, dlen+ddone);
SvPOK_only(dst);
more = (1.0*tlen*SvLEN(dst)+sdone-1)/sdone
- SvLEN(dst);
#elif ENCODE_XS_USEFP
- more = (1.0*SvLEN(dst)+1)/sdone * sleft;
+ more = (STRLEN)((1.0*SvLEN(dst)+1)/sdone * sleft);
#else
/* safe until SvLEN(dst) == MAX_INT/16 */
more = (16*SvLEN(dst)+1)/sdone/16 * sleft;
utf8n_to_uvuni(s+slen, (SvCUR(src)-slen),
&clen, UTF8_ALLOW_ANY|UTF8_CHECK_ONLY);
if (check & ENCODE_DIE_ON_ERR) {
- Perl_croak(
- aTHX_ "\"\\x{%04" UVxf "}\" does not map to %s",
- (UV)ch, enc->name[0]);
+ Perl_croak(aTHX_ ERR_ENCODE_NOMAP,
+ (UV)ch, enc->name[0]);
return &PL_sv_undef; /* never reaches but be safe */
}
if (check & ENCODE_WARN_ON_ERR){
Perl_warner(aTHX_ packWARN(WARN_UTF8),
- "\"\\x{%" UVxf "}\" does not map to %s",
- (UV)ch, enc->name[0]);
+ ERR_ENCODE_NOMAP, (UV)ch, enc->name[0]);
}
if (check & ENCODE_RETURN_ON_ERR){
goto ENCODE_SET_SRC;
/* decoding */
else {
if (check & ENCODE_DIE_ON_ERR){
- Perl_croak(
- aTHX_ "%s \"\\x%02" UVXf
- "\" does not map to Unicode (%d)",
- (UV)enc->name[0], (U8)s[slen], code);
+ Perl_croak(aTHX_ ERR_DECODE_NOMAP,
+ enc->name[0], (UV)s[slen]);
return &PL_sv_undef; /* never reaches but be safe */
}
if (check & ENCODE_WARN_ON_ERR){
Perl_warner(
aTHX_ packWARN(WARN_UTF8),
- "%s \"\\x%02" UVXf
- "\" does not map to Unicode (%d)",
- (UV)enc->name[0], (U8)s[slen], code);
+ ERR_DECODE_NOMAP,
+ enc->name[0], (UV)s[slen]);
}
if (check & ENCODE_RETURN_ON_ERR){
goto ENCODE_SET_SRC;
SV * obj
CODE:
{
- encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
+ /* encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj))); */
ST(0) = &PL_sv_no;
XSRETURN(1);
}
SV * obj
CODE:
{
- encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
+ /* encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj))); */
/* require_pv(PERLIO_FILENAME); */
eval_pv("require PerlIO::encoding", 0);