develooper Front page | perl.perl5.porters | Postings from December 2005

Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
December 3, 2005 23:23
Subject:
Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)
Message ID:
20051204162431.D723.BQW10602@nifty.com

> BTW, would it be sensible to add one or several entries to
> perldiag for the swash_get error messages ?

The patch below reforms all the internal error messages in swash_fetch
and swash_get into the format of "panic: %s" in perldiag.pod.
In the messages reformed, the %s string is a short sentence beginning
with the function name as the subject and unique in the function.
This change should make users easily understand the error is of (P)
and their perl scripts aren't to blame.

(The "illegal mapping" message have been included in perldiag.pod
 already, as "To%s: illegal mapping '%s'")

The change from "%s property definition" to "Unicode property
definition" follows the actual message in swash_init:

        if (SvPOK(retval))
	    Perl_croak(aTHX_ "Can't find Unicode property definition \"%"SVf"\"",
		       retval);

I think "Unicode" is one of important keywords and the keyword should
be included in the entry.  I found no other message with "%s property
definition" where %s isn't "Unicode".

Regards,
SADAHIRO Tomoyuki

diff -ur perl-patch26245/pod/perldiag.pod perl/pod/perldiag.pod
--- perl-patch26245/pod/perldiag.pod	Thu Nov 10 20:23:04 2005
+++ perl/pod/perldiag.pod	Sat Dec 03 17:43:01 2005
@@ -695,15 +695,6 @@
 found in the PATH, or at least not with the correct permissions.  The
 script exists in the current directory, but PATH prohibits running it.
 
-=item Can't find %s property definition %s
-
-(F) You may have tried to use C<\p> which means a Unicode property (for
-example C<\p{Lu}> is all uppercase letters).  If you did mean to use a
-Unicode property, see L<perlunicode> for the list of known properties.
-If you didn't mean to use a Unicode property, escape the C<\p>, either
-by C<\\p> (just the C<\p>) or by C<\Q\p> (the rest of the string, until
-possible C<\E>).
-
 =item Can't find string terminator %s anywhere before EOF
 
 (F) Perl strings can stretch over multiple lines.  This message means
@@ -715,6 +706,15 @@
 If you're getting this error from a here-document, you may have included
 unseen whitespace before or after your closing tag. A good programmer's
 editor will have a way to help you find these characters.
+
+=item Can't find Unicode property definition "%s"
+
+(F) You may have tried to use C<\p> which means a Unicode property (for
+example C<\p{Lu}> is all uppercase letters).  If you did mean to use a
+Unicode property, see L<perlunicode> for the list of known properties.
+If you didn't mean to use a Unicode property, escape the C<\p>, either
+by C<\\p> (just the C<\p>) or by C<\Q\p> (the rest of the string, until
+possible C<\E>).
 
 =item Can't fork
 
diff -ur perl-patch26245/utf8.c perl/utf8.c
--- perl-patch26245/utf8.c	Thu Dec 01 03:25:08 2005
+++ perl/utf8.c	Sun Dec 04 15:47:58 2005
@@ -1704,7 +1704,7 @@
 
 	    if (!svp || !(tmps = (U8*)SvPV(*svp, slen))
 		     || (slen << 3) < needents)
-		Perl_croak(aTHX_ "The swatch does not have proper length");
+		Perl_croak(aTHX_ "panic: swash_fetch got improper swatch");
 	}
 
 	PL_last_swash_hv = hv;
@@ -1730,7 +1730,7 @@
 	off <<= 2;
 	return (tmps[off] << 24) + (tmps[off+1] << 16) + (tmps[off+2] << 8) + tmps[off + 3] ;
     }
-    Perl_croak(aTHX_ "panic: swash_fetch");
+    Perl_croak(aTHX_ "panic: swash_fetch got swatch of unexpected bit width");
     return 0;
 }
 
@@ -1761,7 +1761,8 @@
     UV     end   = start + span;
 
     if (bits != 1 && bits != 8 && bits != 16 && bits != 32) {
-	Perl_croak(aTHX_ "swash_get: unknown bits %"UVuf, (UV) bits);
+	Perl_croak(aTHX_ "panic: swash_get doesn't expect bits %"UVuf,
+						 (UV)bits);
     }
 
     /* create and initialize $swatch */
@@ -1949,28 +1950,23 @@
 	}
 
 	othersvp = hv_fetch(hv, (char *)namestr, namelen, FALSE);
-	if (*othersvp && SvROK(*othersvp) &&
-			 SvTYPE(SvRV(*othersvp))==SVt_PVHV)
-	    otherhv = (HV*)SvRV(*othersvp);
-	else
-	    Perl_croak(aTHX_ "otherhv is not a hash reference");
-
+	otherhv = (HV*)SvRV(*othersvp);
 	otherbitssvp = hv_fetch(otherhv, "BITS", 4, FALSE);
 	otherbits = (STRLEN)SvUV(*otherbitssvp);
 	if (bits < otherbits)
-	    Perl_croak(aTHX_ "swash_get: swatch size mismatch");
+	    Perl_croak(aTHX_ "panic: swash_get found swatch size mismatch");
 
 	/* The "other" swatch must be destroyed after. */
 	other = swash_get(*othersvp, start, span);
 	o = (U8*)SvPV(other, olen);
 
 	if (!olen)
-	    Perl_croak(aTHX_ "swash_get didn't return valid swatch for other");
+	    Perl_croak(aTHX_ "panic: swash_get got improper swatch");
 
 	s = (U8*)SvPV(swatch, slen);
 	if (bits == 1 && otherbits == 1) {
 	    if (slen != olen)
-		Perl_croak(aTHX_ "swash_get: swatch length mismatch");
+		Perl_croak(aTHX_ "panic: swash_get found swatch length mismatch");
 
 	    switch (opc) {
 	    case '+':
###End of patch



Thread Previous | 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