Warn and set errno when open(...,":encoding(xxxxx)",...) cannot find xxxxx.
Nick Ing-Simmons [Sun, 21 Jan 2001 12:56:27 +0000 (12:56 +0000)]
p4raw-id: //depot/perlio@8497

ext/Encode/Encode.xs

index fce3ca4..a4670cd 100644 (file)
@@ -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;