diff options
author | Yves Orton <demerphq@gmail.com> | 2009-10-26 21:52:05 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2009-10-26 23:12:50 +0100 |
commit | 9134ea20ecf6c7a898519ea43ac463bc4da08840 (patch) | |
tree | eac9e42206a5f4b65de593c3eae35518e3ec5feb | |
parent | 2699d6345b651c48a820507d6287ddca1f5b2ee4 (diff) | |
download | perl-9134ea20ecf6c7a898519ea43ac463bc4da08840.tar.gz |
add an elipses to string/ref warnings when str longer than 32 chars
Wasted a few minutes more than necessary trying to work out why the
string was truncated when in fact it was the error message that was
truncating the string.
-rw-r--r-- | perl.h | 4 | ||||
-rw-r--r-- | pp.c | 4 | ||||
-rw-r--r-- | pp_hot.c | 2 | ||||
-rw-r--r-- | t/lib/strict/refs | 8 |
4 files changed, 13 insertions, 5 deletions
@@ -4211,9 +4211,9 @@ EXTCONST char PL_warn_nl[] EXTCONST char PL_no_wrongref[] INIT("Can't use %s ref as %s ref"); EXTCONST char PL_no_symref[] - INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use"); + INIT("Can't use string (\"%.32s\"%s) as %s ref while \"strict refs\" in use"); EXTCONST char PL_no_symref_sv[] - INIT("Can't use string (\"%" SVf32 "\") as %s ref while \"strict refs\" in use"); + INIT("Can't use string (\"%" SVf32 "\"%s) as %s ref while \"strict refs\" in use"); EXTCONST char PL_no_usym[] INIT("Can't use an undefined value as %s reference"); EXTCONST char PL_no_aelem[] @@ -202,7 +202,7 @@ PP(pp_rv2gv) } else { if (PL_op->op_private & HINT_STRICT_REFS) - DIE(aTHX_ PL_no_symref_sv, sv, "a symbol"); + DIE(aTHX_ PL_no_symref_sv, sv, (SvCUR(sv)>32 ? "..." : ""), "a symbol"); if ((PL_op->op_private & (OPpLVAL_INTRO|OPpDONT_INIT_GV)) == OPpDONT_INIT_GV) { /* We are the target of a coderef assignment. Return @@ -232,7 +232,7 @@ Perl_softref2xv(pTHX_ SV *const sv, const char *const what, if (PL_op->op_private & HINT_STRICT_REFS) { if (SvOK(sv)) - Perl_die(aTHX_ PL_no_symref_sv, sv, what); + Perl_die(aTHX_ PL_no_symref_sv, sv, (SvCUR(sv)>32 ? "..." : ""), what); else Perl_die(aTHX_ PL_no_usym, what); } @@ -2700,7 +2700,7 @@ PP(pp_entersub) if (!sym) DIE(aTHX_ PL_no_usym, "a subroutine"); if (PL_op->op_private & HINT_STRICT_REFS) - DIE(aTHX_ PL_no_symref, sym, "a subroutine"); + DIE(aTHX_ PL_no_symref, sym, len>32 ? "..." : "", "a subroutine"); cv = get_cvn_flags(sym, len, GV_ADD|SvUTF8(sv)); break; } diff --git a/t/lib/strict/refs b/t/lib/strict/refs index 075ca4910e..e8f75660b8 100644 --- a/t/lib/strict/refs +++ b/t/lib/strict/refs @@ -19,6 +19,14 @@ EXPECT # strict refs - error use strict ; +my $str="A::Really::Big::Package::Name::To::Use"; +$str->{foo}= 1; +EXPECT +Can't use string ("A::Really::Big::Package::Name::T"...) as a HASH ref while "strict refs" in use at - line 5. +######## + +# strict refs - error +use strict ; my $fred ; my $a = ${"fred"} ; EXPECT |