From 32ca48a2d4d46aa42855266f4e37da8a7342a92d Mon Sep 17 00:00:00 2001
From: Gisle Aas <gisle@aas.no>
Date: Sun, 8 Nov 2009 12:15:58 +0100
Subject: [PATCH] Make the UTF8 encoder croak when callback CHECK is passed in
---
Encode.xs | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/Encode.xs b/Encode.xs
index e5f4c9a..e9ccd3f 100644
--- a/Encode.xs
+++ b/Encode.xs
@@ -401,19 +401,26 @@ MODULE = Encode PACKAGE = Encode::utf8 PREFIX = Method_
PROTOTYPES: DISABLE
void
-Method_decode_xs(obj,src,check = 0)
+Method_decode_xs(obj,src,check_sv = &PL_sv_no)
SV * obj
SV * src
-int check
+SV * check_sv
PREINIT:
STRLEN slen;
U8 *s;
U8 *e;
SV *dst;
bool renewed = 0;
+ int check;
CODE:
{
dSP; ENTER; SAVETMPS;
+ if (SvROK(check_sv)) {
+ croak("UTF-8 decoder doesn't support callback CHECK");
+ }
+ else {
+ check = SvIV(check_sv);
+ }
if (src == &PL_sv_undef) src = newSV(0);
s = (U8 *) SvPV(src, slen);
e = (U8 *) SvEND(src);
@@ -464,18 +471,25 @@ CODE:
}
void
-Method_encode_xs(obj,src,check = 0)
+Method_encode_xs(obj,src,check_sv = &PL_sv_no)
SV * obj
SV * src
-int check
+SV * check_sv
PREINIT:
STRLEN slen;
U8 *s;
U8 *e;
SV *dst;
bool renewed = 0;
+ int check;
CODE:
{
+ if (SvROK(check_sv)) {
+ croak("UTF-8 encoder doesn't support callback CHECK");
+ }
+ else {
+ check = SvIV(check_sv);
+ }
if (src == &PL_sv_undef) src = newSV(0);
s = (U8 *) SvPV(src, slen);
e = (U8 *) SvEND(src);
--
1.6.2.95.g934f7