summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-03-09 11:17:07 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-03-09 11:17:07 +0000
commitb3f66c6826305b811380423899df98c19b2337d3 (patch)
treefe68e8cae28eaa79fb8dd111029d730f4e5089e8 /pp_sys.c
parent3fbd655246e7129e7a25b47b134d3427eecbe312 (diff)
downloadperl-b3f66c6826305b811380423899df98c19b2337d3.tar.gz
patch from Larry to make -T filetest algorithm recognize utf8 as
"text" p4raw-id: //depot/perl@5625
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/pp_sys.c b/pp_sys.c
index da352a2fab..a529b252b7 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3078,9 +3078,26 @@ PP(pp_fttext)
#else
else if (*s & 128) {
#ifdef USE_LOCALE
- if (!(PL_op->op_private & OPpLOCALE) || !isALPHA_LC(*s))
-#endif
- odd++;
+ if ((PL_op->op_private & OPpLOCALE) && isALPHA_LC(*s))
+ continue;
+#endif
+ /* utf8 characters don't count as odd */
+ if (*s & 0x40) {
+ int ulen = UTF8SKIP(s);
+ if (ulen < len - i) {
+ int j;
+ for (j = 1; j < ulen; j++) {
+ if ((s[j] & 0xc0) != 0x80)
+ goto not_utf8;
+ }
+ --ulen; /* loop does extra increment */
+ s += ulen;
+ i += ulen;
+ continue;
+ }
+ }
+ not_utf8:
+ odd++;
}
else if (*s < 32 &&
*s != '\n' && *s != '\r' && *s != '\b' &&