summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-11-27 09:42:48 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-11-28 04:49:13 -0800
commit1b9f127b4dff87fa8c6be8acf741af73f72fea81 (patch)
tree01422b32900632e385bc777a201b15faee83fbf8 /util.c
parente3ef43a5d915565241c254f7c7be154729e81162 (diff)
downloadperl-1b9f127b4dff87fa8c6be8acf741af73f72fea81.tar.gz
Add Perl_foldEQ_latin1()
This function compares two non-utf8 strings to see if they are equivalent without regards to case differences. It does not work nor check for three problematic code points that require special handling: MICRO_SIGN, LATIN_SMALL_LETTER_SHARP_S, and LATIN_SMALL_LETTER_Y_WITH_DIAERESIS. make regen required
Diffstat (limited to 'util.c')
-rw-r--r--util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.c b/util.c
index f3c27f9573..02861f09e5 100644
--- a/util.c
+++ b/util.c
@@ -930,6 +930,27 @@ Perl_foldEQ(const char *s1, const char *s2, register I32 len)
}
return 1;
}
+I32
+Perl_foldEQ_latin1(const char *s1, const char *s2, register I32 len)
+{
+ /* Compare non-utf8 using Unicode (Latin1) semantics. Does not work on
+ * MICRO_SIGN, LATIN_SMALL_LETTER_SHARP_S, nor
+ * LATIN_SMALL_LETTER_Y_WITH_DIAERESIS, and does not check for these. Nor
+ * does it check that the strings each have at least 'len' characters */
+
+ register const U8 *a = (const U8 *)s1;
+ register const U8 *b = (const U8 *)s2;
+
+ PERL_ARGS_ASSERT_FOLDEQ_LATIN1;
+
+ while (len--) {
+ if (*a != *b && *a != PL_fold_latin1[*b]) {
+ return 0;
+ }
+ a++, b++;
+ }
+ return 1;
+}
/*
=for apidoc foldEQ_locale