From cc507455df60f06ecd74b2df5a0ae9f17fb3291d Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Tue, 21 Mar 2000 06:06:44 +0000 Subject: [PATCH] make parenthetic warnings look consistent; make diagnostic on "use 5.6" et al mention the alternate form; pod fixups p4raw-id: //depot/perl@5851 --- gv.c | 2 +- op.c | 8 ++++---- pod/perldelta.pod | 4 ++-- pod/perldiag.pod | 14 +++++++------- pp_ctl.c | 19 +++++++++++++++---- t/comp/use.t | 2 +- t/pragma/strict-vars | 2 +- t/pragma/warn/op | 14 +++++++------- t/pragma/warn/pp_hot | 4 ++-- t/pragma/warn/pp_sys | 28 ++++++++++++++-------------- toke.c | 2 +- universal.c | 4 ++-- util.c | 2 +- 13 files changed, 58 insertions(+), 47 deletions(-) diff --git a/gv.c b/gv.c index eaf2ab1..be19355 100644 --- a/gv.c +++ b/gv.c @@ -631,7 +631,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) sv_type == SVt_PVHV ? '%' : '$', name); if (GvCVu(*gvp)) - Perl_warn(aTHX_ "(Did you mean &%s instead?)\n", name); + Perl_warn(aTHX_ "\t(Did you mean &%s instead?)\n", name); stash = 0; } } diff --git a/op.c b/op.c index 3d55126..1cfc6dd 100644 --- a/op.c +++ b/op.c @@ -168,7 +168,7 @@ Perl_pad_allocmy(pTHX_ char *name) Perl_warner(aTHX_ WARN_MISC, "\"our\" variable %s redeclared", name); Perl_warner(aTHX_ WARN_MISC, - "(Did you mean \"local\" instead of \"our\"?)\n"); + "\t(Did you mean \"local\" instead of \"our\"?)\n"); break; } } while ( off-- > 0 ); @@ -5711,7 +5711,7 @@ Perl_ck_defined(pTHX_ OP *o) /* 19990527 MJD */ Perl_warner(aTHX_ WARN_DEPRECATED, "defined(@array) is deprecated"); Perl_warner(aTHX_ WARN_DEPRECATED, - "(Maybe you should just omit the defined()?)\n"); + "\t(Maybe you should just omit the defined()?)\n"); break; case OP_RV2HV: break; /* Globals via GV can be undef */ @@ -5719,7 +5719,7 @@ Perl_ck_defined(pTHX_ OP *o) /* 19990527 MJD */ Perl_warner(aTHX_ WARN_DEPRECATED, "defined(%%hash) is deprecated"); Perl_warner(aTHX_ WARN_DEPRECATED, - "(Maybe you should just omit the defined()?)\n"); + "\t(Maybe you should just omit the defined()?)\n"); break; default: /* no warning */ @@ -6562,7 +6562,7 @@ Perl_peep(pTHX_ register OP *o) Perl_warner(aTHX_ WARN_EXEC, "Statement unlikely to be reached"); Perl_warner(aTHX_ WARN_EXEC, - "(Maybe you meant system() when you said exec()?)\n"); + "\t(Maybe you meant system() when you said exec()?)\n"); CopLINE_set(PL_curcop, oldline); } } diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 680bcb7..3ee5f1b 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -2079,7 +2079,7 @@ That name might have a meaning to Perl itself some day, even though it doesn't yet. Perhaps you should use a mixed-case attribute name, instead. See L. -=item (in cleanup) %s +=item (in cleanup) %s (W misc) This prefix usually indicates that a DESTROY() method raised the indicated exception. Since destructors are usually called by @@ -2247,7 +2247,7 @@ just use C for example. See Server error. -=item Did you mean "local" instead of "our"? +=item (Did you mean "local" instead of "our"?) (W misc) Remember that "our" does not localize the declared global variable. You have declared it again in the same lexical scope, which seems superfluous. diff --git a/pod/perldiag.pod b/pod/perldiag.pod index a988124..7e41e53 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -248,7 +248,7 @@ Perl yourself. instead of Perl. Check the #! line, or manually feed your script into Perl yourself. -=item (in cleanup) %s +=item (in cleanup) %s (W misc) This prefix usually indicates that a DESTROY() method raised the indicated exception. Since destructors are usually called by @@ -260,7 +260,7 @@ repeated. Failure of user callbacks dispatched using the C flag could also result in this warning. See L. -=item (Missing semicolon on previous line?) +=item (Missing semicolon on previous line?) (S) This is an educated guess made in conjunction with the message "%s found where operator expected". Don't automatically put a semicolon on @@ -1313,16 +1313,16 @@ twisted to write code that triggers this error. See Server error. -=item Did you mean &%s instead? +=item (Did you mean &%s instead?) (W) You probably referred to an imported subroutine &FOO as $FOO or some such. -=item Did you mean "local" instead of "our"? +=item (Did you mean "local" instead of "our"?) (W misc) Remember that "our" does not localize the declared global variable. You have declared it again in the same lexical scope, which seems superfluous. -=item Did you mean $ or @ instead of %? +=item (Did you mean $ or @ instead of %?) (W) You probably said %hash{$key} when you meant $hash{$key} or @hash{@keys}. On the other hand, maybe you just meant %hash and got carried away. @@ -1332,7 +1332,7 @@ On the other hand, maybe you just meant %hash and got carried away. (F) You passed die() an empty string (the equivalent of C) or you called it with no args and both C<$@> and C<$_> were empty. -=item Do you need to predeclare %s? +=item (Do you need to predeclare %s?) (S) This is an educated guess made in conjunction with the message "%s found where operator expected". It often means a subroutine or module @@ -1867,7 +1867,7 @@ double-quotish context. (W pipe) You used the C or C construction, but the command was missing or blank. -=item Missing operator before %s? +=item (Missing operator before %s?) (S) This is an educated guess made in conjunction with the message "%s found where operator expected". Often the missing operator is a comma. diff --git a/pp_ctl.c b/pp_ctl.c index 00fa476..acbcc7e 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2937,7 +2937,7 @@ PP(pp_require) || (PERL_VERSION == ver && PERL_SUBVERSION < sver)))) { - DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only version " + DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only " "v%d.%d.%d, stopped", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); } @@ -2954,9 +2954,20 @@ PP(pp_require) NV nsver = (nver - ver) * 1000; UV sver = (UV)(nsver + 0.0009); - DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only version " - "v%d.%d.%d, stopped", rev, ver, sver, PERL_REVISION, - PERL_VERSION, PERL_SUBVERSION); + /* help out with the "use 5.6" confusion */ + if (sver == 0 && (rev > 5 || (rev == 5 && ver >= 100))) { + DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--" + "this is only v%d.%d.%d, stopped" + " (did you mean v%"UVuf".%"UVuf".0?)", + rev, ver, sver, PERL_REVISION, PERL_VERSION, + PERL_SUBVERSION, rev, ver/100); + } + else { + DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--" + "this is only v%d.%d.%d, stopped", + rev, ver, sver, PERL_REVISION, PERL_VERSION, + PERL_SUBVERSION); + } } } RETPUSHYES; diff --git a/t/comp/use.t b/t/comp/use.t index 89cb31a..1f5fae3 100755 --- a/t/comp/use.t +++ b/t/comp/use.t @@ -153,7 +153,7 @@ print "ok ",$i++,"\n"; print "ok ",$i++,"\n"; eval "use lib v100.105"; - unless ($@ =~ /lib version v100\.105 required--this is only version v35\.36/) { + unless ($@ =~ /lib v100\.105 required--this is only v35\.36/) { print "not "; } print "ok ",$i++,"\n"; diff --git a/t/pragma/strict-vars b/t/pragma/strict-vars index 3d98c54..ae09742 100644 --- a/t/pragma/strict-vars +++ b/t/pragma/strict-vars @@ -395,5 +395,5 @@ our $foo; } EXPECT "our" variable $foo redeclared at - line 7. -(Did you mean "local" instead of "our"?) + (Did you mean "local" instead of "our"?) Name "Foo::foo" used only once: possible typo at - line 9. diff --git a/t/pragma/warn/op b/t/pragma/warn/op index 461f3f6..1a79b4a 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -84,16 +84,16 @@ keys joe ; Statement unlikely to be reached - (Maybe you meant system() when you said exec()? + (Maybe you meant system() when you said exec()? exec "true" ; my $a defined(@array) is deprecated - (Maybe you should just omit the defined()?) + (Maybe you should just omit the defined()?) my @a ; defined @a ; defined (@a = (1,2,3)) ; defined(%hash) is deprecated - (Maybe you should just omit the defined()?) + (Maybe you should just omit the defined()?) my %h ; defined %h ; /---/ should probably be written as "---" @@ -738,28 +738,28 @@ exec "$^X -e 1" ; my $a EXPECT Statement unlikely to be reached at - line 4. -(Maybe you meant system() when you said exec()?) + (Maybe you meant system() when you said exec()?) ######## # op.c use warnings 'deprecated' ; my @a; defined(@a); EXPECT defined(@array) is deprecated at - line 3. -(Maybe you should just omit the defined()?) + (Maybe you should just omit the defined()?) ######## # op.c use warnings 'deprecated' ; defined(@a = (1,2,3)); EXPECT defined(@array) is deprecated at - line 3. -(Maybe you should just omit the defined()?) + (Maybe you should just omit the defined()?) ######## # op.c use warnings 'deprecated' ; my %h; defined(%h); EXPECT defined(%hash) is deprecated at - line 3. -(Maybe you should just omit the defined()?) + (Maybe you should just omit the defined()?) ######## # op.c no warnings 'syntax' ; diff --git a/t/pragma/warn/pp_hot b/t/pragma/warn/pp_hot index baa9f1f..2759057 100644 --- a/t/pragma/warn/pp_hot +++ b/t/pragma/warn/pp_hot @@ -92,7 +92,7 @@ print STDIN "anc"; EXPECT print() on closed filehandle main::STDIN at - line 4. print() on closed filehandle main::STDIN at - line 6. -(Are you trying to call print() on dirhandle main::STDIN?) + (Are you trying to call print() on dirhandle main::STDIN?) ######## # pp_hot.c [pp_rv2av] use warnings 'uninitialized' ; @@ -139,7 +139,7 @@ $a = ; EXPECT readline() on closed filehandle main::STDIN at - line 3. readline() on closed filehandle main::STDIN at - line 4. -(Are you trying to call readline() on dirhandle main::STDIN?) + (Are you trying to call readline() on dirhandle main::STDIN?) ######## # pp_hot.c [Perl_do_readline] use warnings 'io' ; diff --git a/t/pragma/warn/pp_sys b/t/pragma/warn/pp_sys index d428344..7c38727 100644 --- a/t/pragma/warn/pp_sys +++ b/t/pragma/warn/pp_sys @@ -125,7 +125,7 @@ write STDIN; EXPECT write() on closed filehandle main::STDIN at - line 6. write() on closed filehandle main::STDIN at - line 8. -(Are you trying to call write() on dirhandle main::STDIN?) + (Are you trying to call write() on dirhandle main::STDIN?) ######## # pp_sys.c [pp_leavewrite] use warnings 'io' ; @@ -168,7 +168,7 @@ printf STDIN "fred"; EXPECT printf() on closed filehandle main::STDIN at - line 4. printf() on closed filehandle main::STDIN at - line 6. -(Are you trying to call printf() on dirhandle main::STDIN?) + (Are you trying to call printf() on dirhandle main::STDIN?) ######## # pp_sys.c [pp_prtf] use warnings 'io' ; @@ -192,7 +192,7 @@ syswrite STDIN, "fred", 1; EXPECT syswrite() on closed filehandle main::STDIN at - line 4. syswrite() on closed filehandle main::STDIN at - line 6. -(Are you trying to call syswrite() on dirhandle main::STDIN?) + (Are you trying to call syswrite() on dirhandle main::STDIN?) ######## # pp_sys.c [pp_flock] use Config; @@ -217,7 +217,7 @@ flock STDIN, 8; EXPECT flock() on closed filehandle main::STDIN at - line 14. flock() on closed filehandle main::STDIN at - line 16. -(Are you trying to call flock() on dirhandle main::STDIN?) + (Are you trying to call flock() on dirhandle main::STDIN?) ######## # pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername] use warnings 'io' ; @@ -296,25 +296,25 @@ getsockopt() on closed socket main::STDIN at - line 29. getsockname() on closed socket main::STDIN at - line 30. getpeername() on closed socket main::STDIN at - line 31. send() on closed socket main::STDIN at - line 33. -(Are you trying to call send() on dirhandle main::STDIN?) + (Are you trying to call send() on dirhandle main::STDIN?) bind() on closed socket main::STDIN at - line 34. -(Are you trying to call bind() on dirhandle main::STDIN?) + (Are you trying to call bind() on dirhandle main::STDIN?) connect() on closed socket main::STDIN at - line 35. -(Are you trying to call connect() on dirhandle main::STDIN?) + (Are you trying to call connect() on dirhandle main::STDIN?) listen() on closed socket main::STDIN at - line 36. -(Are you trying to call listen() on dirhandle main::STDIN?) + (Are you trying to call listen() on dirhandle main::STDIN?) accept() on closed socket main::STDIN at - line 37. -(Are you trying to call accept() on dirhandle main::STDIN?) + (Are you trying to call accept() on dirhandle main::STDIN?) shutdown() on closed socket main::STDIN at - line 38. -(Are you trying to call shutdown() on dirhandle main::STDIN?) + (Are you trying to call shutdown() on dirhandle main::STDIN?) setsockopt() on closed socket main::STDIN at - line 39. -(Are you trying to call setsockopt() on dirhandle main::STDIN?) + (Are you trying to call setsockopt() on dirhandle main::STDIN?) getsockopt() on closed socket main::STDIN at - line 40. -(Are you trying to call getsockopt() on dirhandle main::STDIN?) + (Are you trying to call getsockopt() on dirhandle main::STDIN?) getsockname() on closed socket main::STDIN at - line 41. -(Are you trying to call getsockname() on dirhandle main::STDIN?) + (Are you trying to call getsockname() on dirhandle main::STDIN?) getpeername() on closed socket main::STDIN at - line 42. -(Are you trying to call getpeername() on dirhandle main::STDIN?) + (Are you trying to call getpeername() on dirhandle main::STDIN?) ######## # pp_sys.c [pp_stat] use warnings 'newline' ; diff --git a/toke.c b/toke.c index 375d917..48dad64 100644 --- a/toke.c +++ b/toke.c @@ -2647,7 +2647,7 @@ Perl_yylex(pTHX) #ifdef PERL_STRICT_CR Perl_warn(aTHX_ "Illegal character \\%03o (carriage return)", '\r'); Perl_croak(aTHX_ - "(Maybe you didn't strip carriage returns after a network transfer?)\n"); + "\t(Maybe you didn't strip carriage returns after a network transfer?)\n"); #endif case ' ': case '\t': case '\f': case 013: s++; diff --git a/universal.c b/universal.c index 28e0896..686d9f8 100644 --- a/universal.c +++ b/universal.c @@ -246,8 +246,8 @@ XS(XS_UNIVERSAL_VERSION) /* they said C and $Foo::VERSION * doesn't look like a float: do string compare */ if (sv_cmp(req,sv) == 1) { - Perl_croak(aTHX_ "%s version v%vd required--" - "this is only version v%vd", + Perl_croak(aTHX_ "%s v%vd required--" + "this is only v%vd", HvNAME(pkg), req, sv); } goto finish; diff --git a/util.c b/util.c index 4b0e1c5..bda2beb 100644 --- a/util.c +++ b/util.c @@ -3817,6 +3817,6 @@ Perl_report_closed_fh(pTHX_ GV *gv, IO *io, const char *func, const char *obj) if (io && IoDIRP(io)) Perl_warner(aTHX_ WARN_CLOSED, - "(Are you trying to call %s() on dirhandle %s?)\n", + "\t(Are you trying to call %s() on dirhandle %s?)\n", func, name); } -- 2.7.4