use strict;
use warnings;
-our $VERSION = "1.28";
+our $VERSION = "1.29";
XSLoader::load 'IO', $VERSION;
sub import {
croak("Negative character number in ungetc()");
v = SvUV(c);
- if (NATIVE_IS_INVARIANT(v) || (v <= 0xFF && !PerlIO_isutf8(handle)))
+ if (UVCHR_IS_INVARIANT(v) || (v <= 0xFF && !PerlIO_isutf8(handle)))
RETVAL = PerlIO_ungetc(handle, (int)v);
else {
U8 buf[UTF8_MAXBYTES + 1], *end;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_BYTE_IS_INVARIANT(ch);
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_BYTE_IS_INVARIANT(ch);
if (hibit) {
start = s = bytes_to_utf8(s, &len);
break;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_BYTE_IS_INVARIANT(ch);
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
PERL_ARGS_ASSERT_APPEND_UTF8_FROM_NATIVE_BYTE;
- if (NATIVE_IS_INVARIANT(byte))
+ if (NATIVE_BYTE_IS_INVARIANT(byte))
*(*dest)++ = byte;
else {
*(*dest)++ = UTF8_EIGHT_BIT_HI(byte);
for (; s < send; s++) {
STRLEN ulen;
UV fc = _to_uni_fold_flags(*s, tmpbuf, &ulen, flags);
- if NATIVE_IS_INVARIANT(fc) {
+ if UVCHR_IS_INVARIANT(fc) {
if (full_folding
&& *s == LATIN_SMALL_LETTER_SHARP_S)
{
from_start = SvPVX_const(sv);
from_end = from_start + SvCUR(sv);
for (from_ptr = from_start; from_ptr < from_end; from_ptr++)
- if (!NATIVE_IS_INVARIANT(*from_ptr)) break;
+ if (!NATIVE_BYTE_IS_INVARIANT(*from_ptr)) break;
if (from_ptr == from_end) {
/* Simple case: no character needs to be changed */
SvUTF8_on(sv);
if ( !UTF ) {
/* store first byte of utf8 representation of
variant codepoints */
- if (! NATIVE_IS_INVARIANT(uvc)) {
+ if (! UVCHR_IS_INVARIANT(uvc)) {
TRIE_BITMAP_SET(trie, UTF8_TWO_BYTE_HI(uvc));
}
}
Newx(dst, *plen_p * 2 + 1, U8);
while (s < *plen_p) {
- if (NATIVE_IS_INVARIANT(src[s]))
+ if (NATIVE_BYTE_IS_INVARIANT(src[s]))
dst[d] = src[s];
else {
dst[d++] = UTF8_EIGHT_BIT_HI(src[s]);
* utf8. If we start to fold non-UTF patterns, be sure to
* update join_exact() */
if (LOC && ender < 256) {
- if (NATIVE_IS_INVARIANT(ender)) {
+ if (UVCHR_IS_INVARIANT(ender)) {
*s = (U8) ender;
foldlen = 1;
} else {
while (t < e) {
const U8 ch = *t++;
- if (NATIVE_IS_INVARIANT(ch)) continue;
+ if (NATIVE_BYTE_IS_INVARIANT(ch)) continue;
t--; /* t already incremented; re-point to first variant */
two_byte_count = 1;
while (d < e) {
const U8 chr = *d++;
- if (! NATIVE_IS_INVARIANT(chr)) two_byte_count++;
+ if (! NATIVE_BYTE_IS_INVARIANT(chr)) two_byte_count++;
}
/* The string will expand by just the number of bytes that
e--;
while (e >= t) {
- if (NATIVE_IS_INVARIANT(*e)) {
+ if (NATIVE_BYTE_IS_INVARIANT(*e)) {
*d-- = *e;
} else {
*d-- = UTF8_EIGHT_BIT_LO(*e);
goto unknown;
uv = (args) ? va_arg(*args, int) : SvIV(argsv);
if ((uv > 255 ||
- (!NATIVE_IS_INVARIANT(uv) && SvUTF8(sv)))
+ (!UVCHR_IS_INVARIANT(uv) && SvUTF8(sv)))
&& !IN_BYTES) {
eptr = (char*)utf8buf;
elen = uvchr_to_utf8((U8*)eptr, uv) - utf8buf;
* to recode the rest of the string into utf8 */
/* Here uv is the ordinal of the next character being added */
- if (!NATIVE_IS_INVARIANT(uv)) {
+ if (!UVCHR_IS_INVARIANT(uv)) {
if (!has_utf8 && uv > 255) {
/* Might need to recode whatever we have accumulated so
* far if it contains any chars variant in utf8 or
default_action:
/* If we started with encoded form, or already know we want it,
then encode the next character */
- if (! NATIVE_IS_INVARIANT((U8)(*s)) && (this_utf8 || has_utf8)) {
+ if (! NATIVE_BYTE_IS_INVARIANT((U8)(*s)) && (this_utf8 || has_utf8)) {
STRLEN len = 1;
/* Append native character for the rev point */
tmpend = uvchr_to_utf8(tmpbuf, rev);
sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf);
- if (!NATIVE_IS_INVARIANT(rev))
+ if (!UVCHR_IS_INVARIANT(rev))
SvUTF8_on(sv);
if (pos + 1 < e && *pos == '.' && isDIGIT(pos[1]))
s = ++pos;
assert(S_or_s == 'S' || S_or_s == 's');
- if (NATIVE_IS_INVARIANT(converted)) { /* No difference between the two for
+ if (UVCHR_IS_INVARIANT(converted)) { /* No difference between the two for
characters in this range */
*p = (U8) converted;
*lenp = 1;
U8 converted = toLOWER_LATIN1(c);
if (p != NULL) {
- if (NATIVE_IS_INVARIANT(converted)) {
+ if (NATIVE_BYTE_IS_INVARIANT(converted)) {
*p = converted;
*lenp = 1;
}
converted = toLOWER_LATIN1(c);
}
- if (NATIVE_IS_INVARIANT(converted)) {
+ if (UVCHR_IS_INVARIANT(converted)) {
*p = (U8) converted;
*lenp = 1;
}
* UTF-8 encoded string) */
#define UTF8_IS_INVARIANT(c) UNI_IS_INVARIANT(NATIVE_UTF8_TO_I8(c))
-#define NATIVE_IS_INVARIANT(c) UNI_IS_INVARIANT(NATIVE_TO_LATIN1(c))
+/* Like the above, but its name implies a non-UTF8 input, and is implemented
+ * differently (for no particular reason) */
+#define NATIVE_BYTE_IS_INVARIANT(c) UNI_IS_INVARIANT(NATIVE_TO_LATIN1(c))
+
+/* Like the above, but accepts any UV as input */
+#define UVCHR_IS_INVARIANT(uv) UNI_IS_INVARIANT(NATIVE_TO_UNI(uv))
#define MAX_PORTABLE_UTF8_TWO_BYTE 0x3FF /* constrained by EBCDIC */