In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/c9d5e35e7efda8acf195b970afb943d0d7481bb4?hp=e812e1e8e98e6f2cf4362feff753023052129851>

- Log -----------------------------------------------------------------
commit c9d5e35e7efda8acf195b970afb943d0d7481bb4
Author: Nicholas Clark <[email protected]>
Date:   Tue Jun 29 19:57:51 2010 +0100

    In pp_require, improve the code generating the exception when no file is 
found.
    
    Make more use of DIE()'s ability to take a *printf formatter and argument 
list,
    hence avoiding most use of SVs as temporary buffers, and building up SVs
    section by section.

M       pp_ctl.c

commit c4ea5f2e1a5dbe46fdaf471d38ffdacf3ce1508e
Author: Nicholas Clark <[email protected]>
Date:   Tue Jun 29 19:54:50 2010 +0100

    Allow the "diag_listed_as" annotation to work on multi-line function calls.
    
    Previously it would only work if the comment was on the line immediately
    preceding the closing /\);/, which was fine for croak()/die()/etc function
    calls all on one line, but not so useful for longer calls.

M       t/porting/diag.t
-----------------------------------------------------------------------

Summary of changes:
 pp_ctl.c         |   36 +++++++++++++++++-------------------
 t/porting/diag.t |    4 +++-
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index 8134187..7d041bd 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3634,34 +3634,32 @@ PP(pp_require)
     SvREFCNT_dec(namesv);
     if (!tryrsfp) {
        if (PL_op->op_type == OP_REQUIRE) {
-           const char *msgstr = name;
            if(errno == EMFILE) {
-               SV * const msg
-                   = sv_2mortal(Perl_newSVpvf(aTHX_ "%s:   %s", msgstr,
-                                              Strerror(errno)));
-               msgstr = SvPV_nolen_const(msg);
+               /* diag_listed_as: Can't locate %s */
+               DIE(aTHX_ "Can't locate %s:   %s", name, Strerror(errno));
            } else {
                if (namesv) {                   /* did we lookup @INC? */
                    AV * const ar = GvAVn(PL_incgv);
                    I32 i;
-                   SV * const msg = sv_2mortal(Perl_newSVpvf(aTHX_ 
-                       "%s in @INC%s%s (@INC contains:",
-                       msgstr,
+                   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?)" : "")
-                                                             ));
-                   
-                   for (i = 0; i <= AvFILL(ar); i++) {
-                       sv_catpvs(msg, " ");
-                       sv_catsv(msg, *av_fetch(ar, i, TRUE));
-                   }
-                   sv_catpvs(msg, ")");
-                   msgstr = SvPV_nolen_const(msg);
-               }    
+                        ? " (did you run h2ph?)" : ""),
+                       inc
+                       );
+               }
            }
-           DIE(aTHX_ "Can't locate %s", msgstr);
+           DIE(aTHX_ "Can't locate %s", name);
        }
 
        RETPUSHUNDEF;
diff --git a/t/porting/diag.t b/t/porting/diag.t
index daec293..7c05172 100755
--- a/t/porting/diag.t
+++ b/t/porting/diag.t
@@ -110,6 +110,7 @@ sub check_file {
     next if /^#/;
     next if /^ * /;
 
+    my $multiline = 0;
     # Loop to accumulate the message text all on one line.
     while (m/$source_msg_re/ and not m/\);$/) {
       my $nextline = <$codefh>;
@@ -127,6 +128,7 @@ sub check_file {
         $nextline =~ s/^"//;
       }
       $_ = "$_$nextline";
+      ++$multiline;
     }
     # This should happen *after* unwrapping, or we don't reformat the things
     # in later lines.
@@ -161,7 +163,7 @@ sub check_file {
         @categories = map {s/^WARN_//; lc $_} split /\s*[|,]\s*/, 
$+{'category'};
     }
     my $name;
-    if ($listed_as and $listed_as_line == $.) {
+    if ($listed_as and $listed_as_line == $. - $multiline) {
         $name = $listed_as;
     } else {
         $name = $+{'text'};

--
Perl5 Master Repository

Reply via email to