From 838f2281125c4e0f98e5d741f9058f09c8242d33 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Thu, 12 Jan 2012 17:22:05 -0300 Subject: Implement the fc keyword and the \F string escape. Along with the simple_casefolding and full_casefolding features. fc() stands for foldcase, a sort of pseudo case (like lowercase), which is used to implement Unicode casefolding. It maps a string to a form where all case differences are erased, so it's a locale-independent way of checking if two strings are the same, regardless of case. This functionality was, and still is, available through the regular expression engine -- /i matches would use casefolding internally. The fc keyword merely exposes this for easier access. Previously, one could attempt to case-insensitively test two strings for equality by doing lc($a) eq lc($b) But that might get you wrong results, for example in the case of \x{DF}, LATIN SMALL LETTER SHARP S. --- keywords.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'keywords.c') diff --git a/keywords.c b/keywords.c index 169a41c411..23d550df83 100644 --- a/keywords.c +++ b/keywords.c @@ -51,7 +51,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) goto unknown; } - case 2: /* 18 tokens of length 2 */ + case 2: /* 19 tokens of length 2 */ switch (name[0]) { case 'd': @@ -70,6 +70,14 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) goto unknown; + case 'f': + if (name[1] == 'c') + { /* fc */ + return (all_keywords || FEATURE_FC_IS_ENABLED ? -KEY_fc : 0); + } + + goto unknown; + case 'g': switch (name[1]) { @@ -3441,5 +3449,5 @@ unknown: } /* Generated from: - * 29732a698b229f9e5f475fbb191f71c335c9e8d05b6168fe29e61c34c4f10bd2 regen/keywords.pl + * e5a540774760ea54c761ef17ee4a153cc264e9a700b817d561e390730c457406 regen/keywords.pl * ex: set ro: */ -- cgit v1.2.1