* the lower-level routine, and it is similarly broken for returning
* multiple values. --jhi */
/* Now SWASHGET is recasted into S_swash_get in this file. */
+
+/* Note:
+ * Returns the value of property/mapping C<swash> for the first character
+ * of the string C<ptr>. If C<do_utf8> is true, the string C<ptr> is
+ * assumed to be in utf8. If C<do_utf8> is false, the string C<ptr> is
+ * assumed to be in native 8-bit encoding. Caches the swatch in C<swash>.
+ */
UV
-Perl_swash_fetch(pTHX_ SV *sv, const U8 *ptr, bool do_utf8)
+Perl_swash_fetch(pTHX_ SV *swash, const U8 *ptr, bool do_utf8)
{
dVAR;
- HV* const hv = (HV*)SvRV(sv);
+ HV* const hv = (HV*)SvRV(swash);
U32 klen;
U32 off;
STRLEN slen;
const UV code_point = utf8n_to_uvuni(ptr, UTF8_MAXBYTES, 0,
ckWARN(WARN_UTF8) ?
0 : UTF8_ALLOW_ANY);
- swatch = swash_get(sv,
+ swatch = swash_get(swash,
/* On EBCDIC & ~(0xA0-1) isn't a useful thing to do */
(klen) ? (code_point & ~(needents - 1)) : 0,
needents);
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;
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;
}
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 */
}
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 '+':