From: Nick Ing-Simmons Date: Sun, 21 Jan 2001 12:56:27 +0000 (+0000) Subject: Warn and set errno when open(...,":encoding(xxxxx)",...) cannot find xxxxx. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52744f63cab71e4f408a2490707f42c331bb389e;p=p5sagit%2Fp5-mst-13.2.git Warn and set errno when open(...,":encoding(xxxxx)",...) cannot find xxxxx. p4raw-id: //depot/perlio@8497 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index fce3ca4..a4670cd 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -64,12 +64,21 @@ PerlIOEncode_pushed(PerlIO *f, const char *mode,const char *arg,STRLEN len) XPUSHs(sv_2mortal(newSVpvn(arg,len))); PUTBACK; if (perl_call_method("getEncoding",G_SCALAR) != 1) - return -1; + { + /* should never happen */ + Perl_die(aTHX_ "Encode::getEncoding did not return a value"); + return -1; + } SPAGAIN; e->enc = POPs; PUTBACK; if (!SvROK(e->enc)) - return -1; + { + e->enc = Nullsv; + errno = EINVAL; + Perl_warner(aTHX_ WARN_IO, "Cannot find encoding \"%.*s\"", (int) len, arg); + return -1; + } SvREFCNT_inc(e->enc); FREETMPS; LEAVE;