This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use new case changing macros
authorKarl Williamson <public@khwilliamson.com>
Thu, 25 Apr 2013 16:07:47 +0000 (10:07 -0600)
committerKarl Williamson <public@khwilliamson.com>
Mon, 20 May 2013 17:01:50 +0000 (11:01 -0600)
The previous commit added macros to do some case changing.  This
commit uses them in the core, where appropriate.

ext/File-Glob/bsd_glob.c
pp.c
utf8.c
utf8.h

index 72d8fc7..7ec24df 100644 (file)
@@ -617,12 +617,12 @@ ci_compare(const void *p, const void *q)
        const char *qq = *(const char **)q;
        int ci;
        while (*pp && *qq) {
-               if (toLOWER(*pp) != toLOWER(*qq))
+               if (toFOLD(*pp) != toFOLD(*qq))
                        break;
                ++pp;
                ++qq;
        }
-       ci = toLOWER(*pp) - toLOWER(*qq);
+       ci = toFOLD(*pp) - toFOLD(*qq);
        if (ci == 0)
                return compare(p, q);
        return ci;
diff --git a/pp.c b/pp.c
index 337c339..bd2d8c9 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4198,18 +4198,15 @@ PP(pp_fc)
        }
     } /* Unflagged string */
     else if (len) {
-        /* For locale, bytes, and nothing, the behavior is supposed to be the
-         * same as lc().
-         */
         if ( IN_LOCALE_RUNTIME ) { /* Under locale */
             TAINT;
             SvTAINTED_on(dest);
             for (; s < send; d++, s++)
-                *d = toLOWER_LC(*s);
+                *d = toFOLD_LC(*s);
         }
         else if ( !IN_UNI_8_BIT ) { /* Under nothing, or bytes */
             for (; s < send; d++, s++)
-                *d = toLOWER(*s);
+                *d = toFOLD(*s);
         }
         else {
             /* For ASCII and the Latin-1 range, there's only two troublesome
diff --git a/utf8.c b/utf8.c
index 9ae1580..90d0722 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2776,7 +2776,7 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b
 
     if (UTF8_IS_INVARIANT(*p)) {
        if (flags & FOLD_FLAGS_LOCALE) {
-           result = toLOWER_LC(*p);
+           result = toFOLD_LC(*p);
        }
        else {
            return _to_fold_latin1(*p, ustrp, lenp,
@@ -2785,7 +2785,7 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b
     }
     else if UTF8_IS_DOWNGRADEABLE_START(*p) {
        if (flags & FOLD_FLAGS_LOCALE) {
-           result = toLOWER_LC(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1)));
+           result = toFOLD_LC(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1)));
        }
        else {
            return _to_fold_latin1(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1)),
@@ -4580,8 +4580,7 @@ Perl_foldEQ_utf8_flags(pTHX_ const char *s1, char **pe1, UV l1, bool u1, const c
                        return 0;
                    }
                    n1 = 1;
-                   *foldbuf1 = toLOWER(*p1);   /* Folds in the ASCII range are
-                                                  just lowercased */
+                   *foldbuf1 = toFOLD(*p1);
                }
                else if (u1) {
                    to_utf8_fold(p1, foldbuf1, &n1);
@@ -4628,7 +4627,7 @@ Perl_foldEQ_utf8_flags(pTHX_ const char *s1, char **pe1, UV l1, bool u1, const c
                        return 0;
                    }
                    n2 = 1;
-                   *foldbuf2 = toLOWER(*p2);
+                   *foldbuf2 = toFOLD(*p2);
                }
                else if (u2) {
                    to_utf8_fold(p2, foldbuf2, &n2);
diff --git a/utf8.h b/utf8.h
index 01d8f5f..ea54a2d 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -504,8 +504,8 @@ Perl's extended UTF-8 means we can have start bytes up to FF.
         (ANYOF_NONBITMAP(node)) && \
         (ANYOF_FLAGS(node) & ANYOF_LOC_NONBITMAP_FOLD) && \
         ((end) > (input) + 1) && \
-        toLOWER((input)[0]) == 's' && \
-        toLOWER((input)[1]) == 's')
+        toFOLD((input)[0]) == 's' && \
+        toFOLD((input)[1]) == 's')
 #define SHARP_S_SKIP 2
 
 /* If you want to exclude surrogates, and beyond legal Unicode, see the blame