This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Expand flags parameter from boolean in _to_fold_latin1
authorKarl Williamson <public@khwilliamson.com>
Sat, 18 May 2013 05:07:05 +0000 (23:07 -0600)
committerKarl Williamson <public@khwilliamson.com>
Mon, 20 May 2013 17:01:52 +0000 (11:01 -0600)
This will be used in future commits to pass more flags.

embed.fnc
proto.h
regcomp.c
regexec.c
utf8.c

index 5923236..8b73d6d 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -633,7 +633,7 @@ iDMPR       |bool   |isALNUM_lazy   |NN const char* p
 sR     |U8     |to_lower_latin1|const U8 c|NULLOK U8 *p|NULLOK STRLEN *lenp
 #endif
 #if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C)
-EXp        |UV        |_to_fold_latin1|const U8 c|NN U8 *p|NN STRLEN *lenp|const bool flags
+EXp        |UV        |_to_fold_latin1|const U8 c|NN U8 *p|NN STRLEN *lenp|const unsigned int flags
 #endif
 #if defined(PERL_IN_UTF8_C) || defined(PERL_IN_PP_C)
 p      |UV     |_to_upper_title_latin1|const U8 c|NN U8 *p|NN STRLEN *lenp|const char S_or_s
diff --git a/proto.h b/proto.h
index c2fe6f3..a1b3e97 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -7457,7 +7457,7 @@ PERL_CALLCONV UV  Perl__to_upper_title_latin1(pTHX_ const U8 c, U8 *p, STRLEN *le
 
 #endif
 #if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C)
-PERL_CALLCONV UV       Perl__to_fold_latin1(pTHX_ const U8 c, U8 *p, STRLEN *lenp, const bool flags)
+PERL_CALLCONV UV       Perl__to_fold_latin1(pTHX_ const U8 c, U8 *p, STRLEN *lenp, const unsigned int flags)
                        __attribute__nonnull__(pTHX_2)
                        __attribute__nonnull__(pTHX_3);
 #define PERL_ARGS_ASSERT__TO_FOLD_LATIN1       \
index bc0e6b3..dfe3aea 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1456,7 +1456,7 @@ is the recommended Unicode-aware way of saying
            len = 0;                                                                     \
         } else {                                                                        \
             len = 1;                                                                    \
-            uvc = _to_fold_latin1( (U8) *uc, foldbuf, &foldlen, 1);                     \
+            uvc = _to_fold_latin1( (U8) *uc, foldbuf, &foldlen, FOLD_FLAGS_FULL);       \
             skiplen = UNISKIP(uvc);                                                     \
             foldlen -= skiplen;                                                         \
             scan = foldbuf + skiplen;                                                   \
index bc38839..4590a81 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1252,7 +1252,7 @@ STMT_START {                               \
             len=0;                                                                  \
         } else {                                                                    \
             len = 1;                                                                \
-            uvc = _to_fold_latin1( (U8) *uc, foldbuf, &foldlen, 1);                 \
+            uvc = _to_fold_latin1( (U8) *uc, foldbuf, &foldlen, FOLD_FLAGS_FULL);   \
             skiplen = UNISKIP( uvc );                                               \
             foldlen -= skiplen;                                                     \
             uscan = foldbuf + skiplen;                                              \
diff --git a/utf8.c b/utf8.c
index 0c95947..0e8274f 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1780,10 +1780,11 @@ Perl_to_uni_lower(pTHX_ UV c, U8* p, STRLEN *lenp)
 }
 
 UV
-Perl__to_fold_latin1(pTHX_ const U8 c, U8* p, STRLEN *lenp, const bool flags)
+Perl__to_fold_latin1(pTHX_ const U8 c, U8* p, STRLEN *lenp, const unsigned int flags)
 {
-    /* Corresponds to to_lower_latin1(), <flags> is TRUE if to use full case
-     * folding */
+    /* Corresponds to to_lower_latin1(); <flags> bits meanings:
+     *     FOLD_FLAGS_FULL  iff full folding is to be used;
+     */
 
     UV converted;
 
@@ -1792,7 +1793,7 @@ Perl__to_fold_latin1(pTHX_ const U8 c, U8* p, STRLEN *lenp, const bool flags)
     if (c == MICRO_SIGN) {
        converted = GREEK_SMALL_LETTER_MU;
     }
-    else if (flags && c == LATIN_SMALL_LETTER_SHARP_S) {
+    else if ((flags & FOLD_FLAGS_FULL) && c == LATIN_SMALL_LETTER_SHARP_S) {
        *(p)++ = 's';
        *p = 's';
        *lenp = 2;
@@ -1831,12 +1832,11 @@ Perl__to_uni_fold_flags(pTHX_ UV c, U8* p, STRLEN *lenp, const U8 flags)
 
     if (c < 256) {
        UV result = _to_fold_latin1((U8) c, p, lenp,
-                              cBOOL(((flags & FOLD_FLAGS_FULL)
                                   /* If ASCII-safe, don't allow full folding,
                                    * as that could include SHARP S => ss;
                                    * otherwise there is no crossing of
                                    * ascii/non-ascii in the latin1 range */
-                                  && ! (flags & FOLD_FLAGS_NOMIX_ASCII))));
+                              (flags & FOLD_FLAGS_NOMIX_ASCII) ? 0 : flags & FOLD_FLAGS_FULL);
        /* It is illegal for the fold to cross the 255/256 boundary under
         * locale; in this case return the original */
        return (result > 256 && flags & FOLD_FLAGS_LOCALE)
@@ -2773,7 +2773,7 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b
        }
        else {
            return _to_fold_latin1(*p, ustrp, lenp,
-                                  cBOOL(flags & FOLD_FLAGS_FULL));
+                            flags & FOLD_FLAGS_FULL);
        }
     }
     else if UTF8_IS_DOWNGRADEABLE_START(*p) {
@@ -2782,14 +2782,13 @@ Perl__to_utf8_fold_flags(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, U8 flags, b
        }
        else {
            return _to_fold_latin1(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1)),
-                                  ustrp, lenp,
-                                  cBOOL((flags & FOLD_FLAGS_FULL
+                            ustrp, lenp,
                                       /* If ASCII safe, don't allow full
                                        * folding, as that could include SHARP
                                        * S => ss; otherwise there is no
                                        * crossing of ascii/non-ascii in the
                                        * latin1 range */
-                                      && ! (flags & FOLD_FLAGS_NOMIX_ASCII))));
+                              (flags & FOLD_FLAGS_NOMIX_ASCII) ? 0 : flags & FOLD_FLAGS_FULL);
        }
     }
     else {  /* utf8, ord above 255 */