develooper Front page | perl.perl5.porters | Postings from June 2012

almost unreachable code in pp_require

Thread Next
From:
Nicholas Clark
Date:
June 27, 2012 08:23
Subject:
almost unreachable code in pp_require
Message ID:
20120627152301.GQ9069@plum.flirble.org
pp_require has this:

    saved_errno = errno; /* sv_2mortal can realloc things */
    sv_2mortal(namesv);
    if (!tryrsfp) {
	if (PL_op->op_type == OP_REQUIRE) {
	    if(saved_errno == EMFILE || saved_errno == EACCES) {
		/* diag_listed_as: Can't locate %s */
		DIE(aTHX_ "Can't locate %s:   %s", name, Strerror(saved_errno));
	    } else {
	        if (namesv) {			/* did we lookup @INC? */
		    AV * const ar = GvAVn(PL_incgv);
		    I32 i;
		    SV *const inc = newSVpvs_flags("", SVs_TEMP);
		    for (i = 0; i <= AvFILL(ar); i++) {
			sv_catpvs(inc, " ");
			sv_catsv(inc, *av_fetch(ar, i, TRUE));
		    }

		    /* diag_listed_as: Can't locate %s */
		    DIE(aTHX_
			"Can't locate %s in @INC%s%s (@INC contains:%" SVf ")",
			name,
			(memEQ(name + len - 2, ".h", 3)
			 ? " (change .h to .ph maybe?) (did you run h2ph?)" : ""),
			(memEQ(name + len - 3, ".ph", 4)
			 ? " (did you run h2ph?)" : ""),
			inc
			);
		}
	    }
	    DIE(aTHX_ "Can't locate %s", name);
	}


Is there any way to reach that last DIE, other than on VMS, like this?

$ perl -e "require q{[fred.--foo.bar]}"
Can't locate [fred.--foo.bar] at -e line 1.
%SYSTEM-F-ABORT, abort

(ie on VMS doing something that forces a NULL return from tounixspec)

I guess that that code path would like a test, but I'm curious whether there
is any way to get there other than on VMS.

(Clearly, it has to be OP_REQUIRE, saved_errno isn't EMFILE or EACCES, and
namesv has to be NULL. I can't see how to meet all those conditions, except
on VMS. Is there a way?)

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About