From: Jarkko Hietaniemi Date: Sat, 13 Sep 2003 10:37:30 +0000 (+0000) Subject: Layer names were recognized by their prefixes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a9f76400719eab0b833a22a7abc257540ba871a5;p=p5sagit%2Fp5-mst-13.2.git Layer names were recognized by their prefixes (e.g. open(F, ":u", "file") worked...) p4raw-id: //depot/perl@21207 --- diff --git a/perlio.c b/perlio.c index 91b7781..a716e70 100644 --- a/perlio.c +++ b/perlio.c @@ -735,7 +735,7 @@ PerlIO_find_layer(pTHX_ const char *name, STRLEN len, int load) len = strlen(name); for (i = 0; i < PL_known_layers->cur; i++) { PerlIO_funcs *f = PL_known_layers->array[i].funcs; - if (memEQ(f->name, name, len)) { + if (memEQ(f->name, name, len) && f->name[len] == 0) { PerlIO_debug("%.*s => %p\n", (int) len, name, (void*)f); return f; } diff --git a/t/io/open.t b/t/io/open.t index b8020c2..90305bd 100755 --- a/t/io/open.t +++ b/t/io/open.t @@ -12,7 +12,7 @@ use Config; $Is_VMS = $^O eq 'VMS'; $Is_MacOS = $^O eq 'MacOS'; -plan tests => 102; +plan tests => 105; my $Perl = which_perl(); @@ -280,15 +280,25 @@ SKIP: { } SKIP: { - skip("This test uses perlio", 1) unless $Config{useperlio}; + skip("These tests use perlio", 5) unless $Config{useperlio}; my $w; use warnings 'layer'; local $SIG{__WARN__} = sub { $w = shift }; eval { open(F, ">>>", "afile") }; like($w, qr/perlio: invalid separator character '>' in layer spec/, - "bad open warning"); + "bad open (>>>) warning"); like($@, qr/Unknown open\(\) mode '>>>'/, - "bad open failure"); + "bad open (>>>) failure"); + + eval { open(F, ">:u", "afile" ) }; + like($w, qr/perlio: unknown layer "u"/, + 'bad layer ">:u" warning'); + eval { open(F, "<:u", "afile" ) }; + like($w, qr/perlio: unknown layer "u"/, + 'bad layer "<:u" warning'); + eval { open(F, ":u", "afile" ) }; + like($@, qr/Unknown open\(\) mode ':u'/, + 'bad layer ":u" failure'); }