This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change name of PL_ variable
authorKarl Williamson <khw@cpan.org>
Mon, 28 Nov 2016 22:22:08 +0000 (15:22 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 29 Nov 2016 00:15:24 +0000 (17:15 -0700)
This variable really means the character that replaces any embedded NULs
when doing collation.  Change the name accordingly.  (Embedded NULs must
be replaced because the libc function strxfrm is used, and it operates
on C strings which have no embedded NULs.)

embedvar.h
intrpvar.h
locale.c

index 575b755..c413932 100644 (file)
 #define PL_stderrgv            (vTHX->Istderrgv)
 #define PL_stdingv             (vTHX->Istdingv)
 #define PL_strtab              (vTHX->Istrtab)
 #define PL_stderrgv            (vTHX->Istderrgv)
 #define PL_stdingv             (vTHX->Istdingv)
 #define PL_strtab              (vTHX->Istrtab)
+#define PL_strxfrm_NUL_replacement     (vTHX->Istrxfrm_NUL_replacement)
 #define PL_strxfrm_is_behaved  (vTHX->Istrxfrm_is_behaved)
 #define PL_strxfrm_max_cp      (vTHX->Istrxfrm_max_cp)
 #define PL_strxfrm_is_behaved  (vTHX->Istrxfrm_is_behaved)
 #define PL_strxfrm_max_cp      (vTHX->Istrxfrm_max_cp)
-#define PL_strxfrm_min_char    (vTHX->Istrxfrm_min_char)
 #define PL_sub_generation      (vTHX->Isub_generation)
 #define PL_subline             (vTHX->Isubline)
 #define PL_subname             (vTHX->Isubname)
 #define PL_sub_generation      (vTHX->Isub_generation)
 #define PL_subline             (vTHX->Isubline)
 #define PL_subname             (vTHX->Isubname)
index db6251c..1aa94f7 100644 (file)
@@ -565,8 +565,7 @@ PERLVAR(I, collation_name, char *)  /* Name of current collation */
 PERLVAR(I, collxfrm_base, Size_t)      /* Basic overhead in *xfrm() */
 PERLVARI(I, collxfrm_mult,Size_t, 2)   /* Expansion factor in *xfrm() */
 PERLVARI(I, collation_ix, U32, 0)      /* Collation generation index */
 PERLVAR(I, collxfrm_base, Size_t)      /* Basic overhead in *xfrm() */
 PERLVARI(I, collxfrm_mult,Size_t, 2)   /* Expansion factor in *xfrm() */
 PERLVARI(I, collation_ix, U32, 0)      /* Collation generation index */
-PERLVARI(I, strxfrm_min_char, U8, 0)    /* Code point that sorts earliest in
-                                           locale */
+PERLVARI(I, strxfrm_NUL_replacement, U8, 0)  /* Code point to replace NULs */
 PERLVARI(I, strxfrm_is_behaved, bool, TRUE)
                             /* Assume until proven otherwise that it works */
 PERLVARI(I, strxfrm_max_cp, U8, 0)      /* Highest collating cp in locale */
 PERLVARI(I, strxfrm_is_behaved, bool, TRUE)
                             /* Assume until proven otherwise that it works */
 PERLVARI(I, strxfrm_max_cp, U8, 0)      /* Highest collating cp in locale */
index a93573e..a871b9e 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -514,7 +514,7 @@ Perl_new_collate(pTHX_ const char *newcoll)
        PL_collxfrm_base = 0;
        PL_collxfrm_mult = 2;
         PL_in_utf8_COLLATE_locale = FALSE;
        PL_collxfrm_base = 0;
        PL_collxfrm_mult = 2;
         PL_in_utf8_COLLATE_locale = FALSE;
-        PL_strxfrm_min_char = '\0';
+        PL_strxfrm_NUL_replacement = '\0';
         PL_strxfrm_max_cp = 0;
        return;
     }
         PL_strxfrm_max_cp = 0;
        return;
     }
@@ -530,7 +530,7 @@ Perl_new_collate(pTHX_ const char *newcoll)
         }
 
         PL_in_utf8_COLLATE_locale = _is_cur_LC_category_utf8(LC_COLLATE);
         }
 
         PL_in_utf8_COLLATE_locale = _is_cur_LC_category_utf8(LC_COLLATE);
-        PL_strxfrm_min_char = '\0';
+        PL_strxfrm_NUL_replacement = '\0';
         PL_strxfrm_max_cp = 0;
 
         /* A locale collation definition includes primary, secondary, tertiary,
         PL_strxfrm_max_cp = 0;
 
         /* A locale collation definition includes primary, secondary, tertiary,
@@ -1478,7 +1478,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
 
         /* If we don't know what non-NUL control character sorts lowest for
          * this locale, find it */
 
         /* If we don't know what non-NUL control character sorts lowest for
          * this locale, find it */
-        if (PL_strxfrm_min_char == '\0') {
+        if (PL_strxfrm_NUL_replacement == '\0') {
             int j;
             char * cur_min_x = NULL;    /* The min_char's xfrm, (except it also
                                            includes the collation index
             int j;
             char * cur_min_x = NULL;    /* The min_char's xfrm, (except it also
                                            includes the collation index
@@ -1530,7 +1530,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
                         || strLT(x         + COLLXFRM_HDR_LEN,
                                  cur_min_x + COLLXFRM_HDR_LEN))
                     {
                         || strLT(x         + COLLXFRM_HDR_LEN,
                                  cur_min_x + COLLXFRM_HDR_LEN))
                     {
-                        PL_strxfrm_min_char = j;
+                        PL_strxfrm_NUL_replacement = j;
                         cur_min_x = x;
                     }
                     else {
                         cur_min_x = x;
                     }
                     else {
@@ -1559,20 +1559,22 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
 
             DEBUG_L(PerlIO_printf(Perl_debug_log,
                     "_mem_collxfrm: Replacing embedded NULs in locale %s with "
 
             DEBUG_L(PerlIO_printf(Perl_debug_log,
                     "_mem_collxfrm: Replacing embedded NULs in locale %s with "
-                    "0x%02X\n", PL_collation_name, PL_strxfrm_min_char));
+                    "0x%02X\n", PL_collation_name, PL_strxfrm_NUL_replacement));
 
             Safefree(cur_min_x);
         } /* End of determining the character that is to replace NULs */
 
         /* If the replacement is variant under UTF-8, it must match the
          * UTF8-ness as the original */
 
             Safefree(cur_min_x);
         } /* End of determining the character that is to replace NULs */
 
         /* If the replacement is variant under UTF-8, it must match the
          * UTF8-ness as the original */
-        if ( ! UVCHR_IS_INVARIANT(PL_strxfrm_min_char) && utf8) {
-            this_replacement_char[0] = UTF8_EIGHT_BIT_HI(PL_strxfrm_min_char);
-            this_replacement_char[1] = UTF8_EIGHT_BIT_LO(PL_strxfrm_min_char);
+        if ( ! UVCHR_IS_INVARIANT(PL_strxfrm_NUL_replacement) && utf8) {
+            this_replacement_char[0] =
+                                UTF8_EIGHT_BIT_HI(PL_strxfrm_NUL_replacement);
+            this_replacement_char[1] =
+                                UTF8_EIGHT_BIT_LO(PL_strxfrm_NUL_replacement);
             this_replacement_len = 2;
         }
         else {
             this_replacement_len = 2;
         }
         else {
-            this_replacement_char[0] = PL_strxfrm_min_char;
+            this_replacement_char[0] = PL_strxfrm_NUL_replacement;
             /* this_replacement_char[1] = '\0' was done at initialization */
             this_replacement_len = 1;
         }
             /* this_replacement_char[1] = '\0' was done at initialization */
             this_replacement_len = 1;
         }