/* Unicode support */
-char *
-uv_to_utf8(unsigned char *d, UV uv)
+U8 *
+uv_to_utf8(U8 *d, UV uv)
{
if (uv < 0x80) {
*d++ = uv;
}
UV
-utf8_to_uv(unsigned char* s, I32* retlen)
+utf8_to_uv(U8* s, I32* retlen)
{
UV uv = *s;
int len;
/* utf8_distance(a,b) is intended to be a - b in pointer arithmetic */
I32
-utf8_distance(unsigned char *a, unsigned char *b)
+utf8_distance(U8 *a, U8 *b)
{
I32 off = 0;
if (a < b) {
/* WARNING: do not use the following unless you *know* off is within bounds */
U8 *
-utf8_hop(unsigned char *s, I32 off)
+utf8_hop(U8 *s, I32 off)
{
if (off >= 0) {
while (off--)
bool
is_uni_alnum(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_alnum(tmpbuf);
}
bool
is_uni_idfirst(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_idfirst(tmpbuf);
}
bool
is_uni_alpha(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_alpha(tmpbuf);
}
bool
is_uni_space(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_space(tmpbuf);
}
bool
is_uni_digit(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_digit(tmpbuf);
}
bool
is_uni_upper(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_upper(tmpbuf);
}
bool
is_uni_lower(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_lower(tmpbuf);
}
bool
is_uni_print(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return is_utf8_print(tmpbuf);
}
U32
to_uni_upper(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return to_utf8_upper(tmpbuf);
}
U32
to_uni_title(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return to_utf8_title(tmpbuf);
}
U32
to_uni_lower(U32 c)
{
- char tmpbuf[10];
+ U8 tmpbuf[10];
uv_to_utf8(tmpbuf, (UV)c);
return to_utf8_lower(tmpbuf);
}
bool
-is_utf8_alnum(unsigned char *p)
+is_utf8_alnum(U8 *p)
{
if (!PL_utf8_alnum)
- PL_utf8_alnum = swash_init("utf8", "IsAlnum", &sv_undef, 0, 0);
+ PL_utf8_alnum = swash_init("utf8", "IsAlnum", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_alnum, p);
/* return *p == '_' || is_utf8_alpha(p) || is_utf8_digit(p); */
#ifdef SURPRISINGLY_SLOWER /* probably because alpha is usually true */
}
bool
-is_utf8_idfirst(unsigned char *p)
+is_utf8_idfirst(U8 *p)
{
return *p == '_' || is_utf8_alpha(p);
}
bool
-is_utf8_alpha(unsigned char *p)
+is_utf8_alpha(U8 *p)
{
if (!PL_utf8_alpha)
- PL_utf8_alpha = swash_init("utf8", "IsAlpha", &sv_undef, 0, 0);
+ PL_utf8_alpha = swash_init("utf8", "IsAlpha", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_alpha, p);
}
bool
-is_utf8_space(unsigned char *p)
+is_utf8_space(U8 *p)
{
if (!PL_utf8_space)
- PL_utf8_space = swash_init("utf8", "IsSpace", &sv_undef, 0, 0);
+ PL_utf8_space = swash_init("utf8", "IsSpace", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_space, p);
}
bool
-is_utf8_digit(unsigned char *p)
+is_utf8_digit(U8 *p)
{
if (!PL_utf8_digit)
- PL_utf8_digit = swash_init("utf8", "IsDigit", &sv_undef, 0, 0);
+ PL_utf8_digit = swash_init("utf8", "IsDigit", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_digit, p);
}
bool
-is_utf8_upper(unsigned char *p)
+is_utf8_upper(U8 *p)
{
if (!PL_utf8_upper)
- PL_utf8_upper = swash_init("utf8", "IsUpper", &sv_undef, 0, 0);
+ PL_utf8_upper = swash_init("utf8", "IsUpper", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_upper, p);
}
bool
-is_utf8_lower(unsigned char *p)
+is_utf8_lower(U8 *p)
{
if (!PL_utf8_lower)
- PL_utf8_lower = swash_init("utf8", "IsLower", &sv_undef, 0, 0);
+ PL_utf8_lower = swash_init("utf8", "IsLower", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_lower, p);
}
bool
-is_utf8_print(unsigned char *p)
+is_utf8_print(U8 *p)
{
if (!PL_utf8_print)
- PL_utf8_print = swash_init("utf8", "IsPrint", &sv_undef, 0, 0);
+ PL_utf8_print = swash_init("utf8", "IsPrint", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_print, p);
}
bool
-is_utf8_mark(unsigned char *p)
+is_utf8_mark(U8 *p)
{
if (!PL_utf8_mark)
- PL_utf8_mark = swash_init("utf8", "IsM", &sv_undef, 0, 0);
+ PL_utf8_mark = swash_init("utf8", "IsM", &PL_sv_undef, 0, 0);
return swash_fetch(PL_utf8_mark, p);
}
-U32
-to_utf8_upper(unsigned char *p)
+UV
+to_utf8_upper(U8 *p)
{
UV uv;
if (!PL_utf8_toupper)
- PL_utf8_toupper = swash_init("utf8", "ToUpper", &sv_undef, 4, 0);
+ PL_utf8_toupper = swash_init("utf8", "ToUpper", &PL_sv_undef, 4, 0);
uv = swash_fetch(PL_utf8_toupper, p);
return uv ? uv : utf8_to_uv(p,0);
}
-U32
-to_utf8_title(unsigned char *p)
+UV
+to_utf8_title(U8 *p)
{
UV uv;
if (!PL_utf8_totitle)
- PL_utf8_totitle = swash_init("utf8", "ToTitle", &sv_undef, 4, 0);
+ PL_utf8_totitle = swash_init("utf8", "ToTitle", &PL_sv_undef, 4, 0);
uv = swash_fetch(PL_utf8_totitle, p);
return uv ? uv : utf8_to_uv(p,0);
}
-U32
-to_utf8_lower(unsigned char *p)
+UV
+to_utf8_lower(U8 *p)
{
UV uv;
if (!PL_utf8_tolower)
- PL_utf8_tolower = swash_init("utf8", "ToLower", &sv_undef, 4, 0);
+ PL_utf8_tolower = swash_init("utf8", "ToLower", &PL_sv_undef, 4, 0);
uv = swash_fetch(PL_utf8_tolower, p);
return uv ? uv : utf8_to_uv(p,0);
}
SAVEI32(PL_hints);
PL_hints = 0;
save_re_context();
- if (curcop == &compiling) /* XXX ought to be handled by lex_start */
+ if (PL_curcop == &PL_compiling) /* XXX ought to be handled by lex_start */
strncpy(tmpbuf, PL_tokenbuf, sizeof tmpbuf);
if (perl_call_method("SWASHNEW", G_SCALAR))
- retval = newSVsv(*stack_sp--);
+ retval = newSVsv(*PL_stack_sp--);
else
- retval = &sv_undef;
+ retval = &PL_sv_undef;
LEAVE;
POPSTACK;
- if (curcop == &compiling) {
+ if (PL_curcop == &PL_compiling) {
strncpy(PL_tokenbuf, tmpbuf, sizeof tmpbuf);
- curcop->op_private = PL_hints;
+ PL_curcop->op_private = PL_hints;
}
if (!SvROK(retval) || SvTYPE(SvRV(retval)) != SVt_PVHV)
croak("SWASHNEW didn't return an HV ref");
}
UV
-swash_fetch(SV *sv, unsigned char *ptr)
+swash_fetch(SV *sv, U8 *ptr)
{
HV* hv = (HV*)SvRV(sv);
U32 klen = UTF8SKIP(ptr) - 1;
U32 off = ptr[klen] & 127; /* NB: 64 bit always 0 when len > 1 */
STRLEN slen;
STRLEN needents = (klen ? 64 : 128);
- unsigned char *tmps;
+ U8 *tmps;
U32 bit;
SV *retval;
}
else {
/* Try our second-level swatch cache, kept in a hash. */
- SV** svp = hv_fetch(hv, ptr, klen, FALSE);
+ SV** svp = hv_fetch(hv, (char*)ptr, klen, FALSE);
/* If not cached, generate it via utf8::SWASHGET */
- if (!svp || !SvPOK(*svp) || !(tmps = SvPV(*svp, slen))) {
+ if (!svp || !SvPOK(*svp) || !(tmps = (U8*)SvPV(*svp, slen))) {
dSP;
ENTER;
SAVETMPS;
PUSHs(sv_2mortal(newSViv(needents)));
PUTBACK;
if (perl_call_method("SWASHGET", G_SCALAR))
- retval = newSVsv(*stack_sp--);
+ retval = newSVsv(*PL_stack_sp--);
else
- retval = &sv_undef;
+ retval = &PL_sv_undef;
POPSTACK;
FREETMPS;
LEAVE;
- if (curcop == &compiling)
- curcop->op_private = PL_hints;
+ if (PL_curcop == &PL_compiling)
+ PL_curcop->op_private = PL_hints;
- svp = hv_store(hv, ptr, klen, retval, 0);
+ svp = hv_store(hv, (char*)ptr, klen, retval, 0);
- if (!svp || !(tmps = SvPV(*svp, slen)) || slen < 8)
+ if (!svp || !(tmps = (U8*)SvPV(*svp, slen)) || slen < 8)
croak("SWASHGET didn't return result of proper length");
}