A fix of sorts for 20000329.026, a better error message
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 5 Nov 2000 17:22:01 +0000 (17:22 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 5 Nov 2000 17:22:01 +0000 (17:22 +0000)
for a missing "use charnames" when using the \N{...}.

p4raw-id: //depot/perl@7557

pod/perldiag.pod
toke.c

index 452938c..20a4a76 100644 (file)
@@ -1086,7 +1086,7 @@ on I<Mastering Regular Expressions>.)
 to check the return value of your socket() call?  See
 L<perlfunc/connect>.
 
-=item constant(%s): %s
+=item Constant(%s)%s: %s
 
 (F) The parser found inconsistencies either while attempting to define
 an overloaded constant, or when trying to find the character name
diff --git a/toke.c b/toke.c
index 274e506..64b6925 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -5749,14 +5749,23 @@ S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv,
     if (!table || !(PL_hints & HINT_LOCALIZE_HH)) {
        SV *msg;
        
-       why1 = "%^H is not consistent";
        why2 = strEQ(key,"charnames")
-              ? " (missing \"use charnames ...\"?)"
+              ? "(possibly a missing \"use charnames ...\")"
               : "";
-       why3 = "";
+       msg = Perl_newSVpvf(aTHX_ "Constant(%s) unknown: %s", 
+                           (type ? type: "undef"), why2);
+
+       /* This is convoluted and evil ("goto considered harmful")
+        * but I do not understand the intricacies of all the different
+        * failure modes of %^H in here.  The goal here is to make
+        * the most probable error message user-friendly. --jhi */
+
+       goto msgdone;
+
     report:
-       msg = Perl_newSVpvf(aTHX_ "constant(%s): %s%s%s", 
+       msg = Perl_newSVpvf(aTHX_ "Constant(%s): %s%s%s", 
                            (type ? type: "undef"), why1, why2, why3);
+    msgdone:
        yyerror(SvPVX(msg));
        SvREFCNT_dec(msg);
        return sv;