In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/63f7ae8a68df6ebb07a1789dbeb05e7d8d011474?hp=d9e2553cbadc371a615c0363a9d9424817047189>

- Log -----------------------------------------------------------------
commit 63f7ae8a68df6ebb07a1789dbeb05e7d8d011474
Author: Karl Williamson <[email protected]>
Date:   Sat Sep 9 22:36:37 2017 -0600

    util.c: Add comments
    
    Better describe my_strftime(), and indicate authorship of long comment
    that has a bunch of 'I' statements.

M       util.c

commit 0f18619da2d26b8d779ec5be72cf9195a5e11403
Author: Karl Williamson <[email protected]>
Date:   Mon Aug 28 13:53:45 2017 -0600

    sv.c: Use modern macro names
    
    This used older names for some locale functions, that have been
    superseded by more meaningful ones.

M       sv.c

commit ffd0a9d37933ebd091d566f4007611170713baf0
Author: Karl Williamson <[email protected]>
Date:   Thu Aug 10 15:27:15 2017 -0600

    utf8.c: Use mnemonic for repeatedly used number

M       utf8.c

commit fd43f63c0d99146b70be91253babfaef4d56d184
Author: Karl Williamson <[email protected]>
Date:   Sat Jul 22 15:19:13 2017 -0600

    locale.c: Add a branch prediction

M       locale.c

commit ae683a5f24cda78d8dfdc8122605e94816caace1
Author: Karl Williamson <[email protected]>
Date:   Sat Jul 22 15:16:38 2017 -0600

    handy.h: White space only
    
    ALign some things vertically for easier reading

M       handy.h

commit a248e8c9a34d31406328ded9f53f37b610ec1290
Author: Karl Williamson <[email protected]>
Date:   Sat Jul 22 15:09:28 2017 -0600

    util.c: atos_symbolize: Don't use locale-dependent fcns
    
    It very likely isn't an issue here, but the core should not have
    unintentional locale-dependent code .

M       util.c

commit 6069d6c5d1109837259a2e1dcf38c27c6b71c8df
Author: Karl Williamson <[email protected]>
Date:   Sat Jul 22 12:44:16 2017 -0600

    locale.c: Don't be too clever in strlcat
    
    This code I wrote was attempting to avoid multiple calls to strlen in
    constructing the catenation of various components of a string.  It did
    this by keeping track of how far it got each iteration, and using that
    as a starting point for the next.  I now realize that the return value
    of strlcat is as if it succeeds, even if there isn't enough room.  That
    means that if there were a problem, this could start out an iteration
    such that it would be writing beyond the end of the buffer.  It is safer
    to not do this, so this commit removes it.
    
    The use of strlcat is a safety measure, as there should be a sufficient
    amount of space calculated for things to fit, so there is no bug here.
    But one should be safe.

M       locale.c

commit 08b6dc1dd594e877912f45d19ed34b0293159bab
Author: Karl Williamson <[email protected]>
Date:   Thu Jul 20 18:21:13 2017 -0600

    locale.c: Use %z to specify printf format for length
    
    This is the better way to do this.

M       locale.c
-----------------------------------------------------------------------

Summary of changes:
 handy.h  |  8 ++++----
 locale.c | 17 ++++++-----------
 sv.c     |  8 ++++----
 utf8.c   |  6 ++++--
 util.c   | 18 +++++++++++++-----
 5 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/handy.h b/handy.h
index 7ef7e253b7..31afaae65e 100644
--- a/handy.h
+++ b/handy.h
@@ -1402,7 +1402,7 @@ END_EXTERN_C
 #   define isGRAPH_L1(c)     (isPRINT_L1(c) && (! isBLANK_L1(c)))
 #   define isLOWER_L1(c)     (isLOWER_A(c)                                   \
                               || (FITS_IN_8_BITS(c)                          \
-                                  && ((NATIVE_TO_LATIN1((U8) c) >= 0xDF      \
+                                  && ((   NATIVE_TO_LATIN1((U8) c) >= 0xDF   \
                                        && NATIVE_TO_LATIN1((U8) c) != 0xF7)  \
                                        || NATIVE_TO_LATIN1((U8) c) == 0xAA   \
                                        || NATIVE_TO_LATIN1((U8) c) == 0xBA   \
@@ -1412,7 +1412,7 @@ END_EXTERN_C
                                   && NATIVE_TO_LATIN1((U8) c) >= 0xA0))
 #   define isPUNCT_L1(c)     (isPUNCT_A(c)                                   \
                               || (FITS_IN_8_BITS(c)                          \
-                                  && (NATIVE_TO_LATIN1((U8) c) == 0xA1       \
+                                  && (   NATIVE_TO_LATIN1((U8) c) == 0xA1    \
                                       || NATIVE_TO_LATIN1((U8) c) == 0xA7    \
                                       || NATIVE_TO_LATIN1((U8) c) == 0xAB    \
                                       || NATIVE_TO_LATIN1((U8) c) == 0xB6    \
@@ -1421,11 +1421,11 @@ END_EXTERN_C
                                       || NATIVE_TO_LATIN1((U8) c) == 0xBF)))
 #   define isSPACE_L1(c)     (isSPACE_A(c)                                   \
                               || (FITS_IN_8_BITS(c)                          \
-                                  && (NATIVE_TO_LATIN1((U8) c) == 0x85       \
+                                  && (   NATIVE_TO_LATIN1((U8) c) == 0x85    \
                                       || NATIVE_TO_LATIN1((U8) c) == 0xA0)))
 #   define isUPPER_L1(c)     (isUPPER_A(c)                                   \
                               || (FITS_IN_8_BITS(c)                          \
-                                  && (NATIVE_TO_LATIN1((U8) c) >= 0xC0       \
+                                  && (   NATIVE_TO_LATIN1((U8) c) >= 0xC0    \
                                       && NATIVE_TO_LATIN1((U8) c) <= 0xDE    \
                                       && NATIVE_TO_LATIN1((U8) c) != 0xD7)))
 #   define isWORDCHAR_L1(c)  (isIDFIRST_L1(c) || isDIGIT_A(c))
diff --git a/locale.c b/locale.c
index 8f64ef7f5d..4189a6248d 100644
--- a/locale.c
+++ b/locale.c
@@ -2224,11 +2224,11 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
      * otherwise contain that character, but otherwise there may be
      * less-than-perfect results with that character and NUL.  This is
      * unavoidable unless we replace strxfrm with our own implementation. */
-    if (s_strlen < len) {   /* Only execute if there is an embedded NUL */
+    if (UNLIKELY(s_strlen < len)) {   /* Only execute if there is an embedded
+                                         NUL */
         char * e = s + len;
         char * sans_nuls;
         STRLEN sans_nuls_len;
-        STRLEN sans_nuls_pos;
         int try_non_controls;
         char this_replacement_char[] = "?\0";   /* Room for a two-byte string,
                                                    making sure 2nd byte is NUL.
@@ -2347,19 +2347,14 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
         sans_nuls_len = (len * this_replacement_len) + 1;
         Newx(sans_nuls, sans_nuls_len, char);
         *sans_nuls = '\0';
-        sans_nuls_pos = 0;
 
         /* Replace each NUL with the lowest collating control.  Loop until have
          * exhausted all the NULs */
         while (s + s_strlen < e) {
-            sans_nuls_pos = my_strlcat(sans_nuls + sans_nuls_pos,
-                                       s,
-                                       sans_nuls_len);
+            my_strlcat(sans_nuls, s, sans_nuls_len);
 
             /* Do the actual replacement */
-            sans_nuls_pos = my_strlcat(sans_nuls + sans_nuls_pos,
-                                       this_replacement_char,
-                                       sans_nuls_len);
+            my_strlcat(sans_nuls, this_replacement_char, sans_nuls_len);
 
             /* Move past the input NUL */
             s += s_strlen + 1;
@@ -2367,7 +2362,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
         }
 
         /* And add anything that trails the final NUL */
-        my_strlcat(sans_nuls + sans_nuls_pos, s, sans_nuls_len);
+        my_strlcat(sans_nuls, s, sans_nuls_len);
 
         /* Switch so below we transform this modified string */
         s = sans_nuls;
@@ -2712,7 +2707,7 @@ S_print_collxfrm_input_and_return(pTHX_
     PerlIO_printf(Perl_debug_log, "_mem_collxfrm[%" UVuf "]: returning ",
                                                         (UV)PL_collation_ix);
     if (xlen) {
-        PerlIO_printf(Perl_debug_log, "%" UVuf, (UV) *xlen);
+        PerlIO_printf(Perl_debug_log, "%zu", *xlen);
     }
     else {
         PerlIO_printf(Perl_debug_log, "NULL");
diff --git a/sv.c b/sv.c
index 7a3a5fcde6..6dcd99ae59 100644
--- a/sv.c
+++ b/sv.c
@@ -2666,11 +2666,11 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
        /* The logic to use SVt_PVNV if necessary is in sv_upgrade.  */
        sv_upgrade(sv, SVt_NV);
        DEBUG_c({
-           STORE_NUMERIC_LOCAL_SET_STANDARD();
+           STORE_LC_NUMERIC_UNDERLYING_SET_STANDARD();
            PerlIO_printf(Perl_debug_log,
                          "0x%" UVxf " num(%" NVgf ")\n",
                          PTR2UV(sv), SvNVX(sv));
-           RESTORE_NUMERIC_LOCAL();
+           RESTORE_LC_NUMERIC_UNDERLYING();
        });
     }
     else if (SvTYPE(sv) < SVt_PVNV)
@@ -2807,10 +2807,10 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
        return 0.0;
     }
     DEBUG_c({
-       STORE_NUMERIC_LOCAL_SET_STANDARD();
+       STORE_LC_NUMERIC_UNDERLYING_SET_STANDARD();
        PerlIO_printf(Perl_debug_log, "0x%" UVxf " 2nv(%" NVgf ")\n",
                      PTR2UV(sv), SvNVX(sv));
-       RESTORE_NUMERIC_LOCAL();
+       RESTORE_LC_NUMERIC_UNDERLYING();
     });
     return SvNVX(sv);
 }
diff --git a/utf8.c b/utf8.c
index d6ff21ab08..8ffa5dd129 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2388,10 +2388,12 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 
*newlen)
            *d++ = UTF8_TWO_BYTE_LO(UNI_TO_NATIVE(uv));
            continue;
        }
+
 #define FIRST_HIGH_SURROGATE UNICODE_SURROGATE_FIRST
 #define LAST_HIGH_SURROGATE  0xDBFF
 #define FIRST_LOW_SURROGATE  0xDC00
 #define LAST_LOW_SURROGATE   UNICODE_SURROGATE_LAST
+#define FIRST_IN_PLANE1      0x10000
 
         /* This assumes that most uses will be in the first Unicode plane, not
          * needing surrogates */
@@ -2410,13 +2412,13 @@ Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 
*newlen)
                 }
                p += 2;
                uv = ((uv - FIRST_HIGH_SURROGATE) << 10)
-                                       + (low - FIRST_LOW_SURROGATE) + 0x10000;
+                                + (low - FIRST_LOW_SURROGATE) + 
FIRST_IN_PLANE1;
            }
        }
 #ifdef EBCDIC
         d = uvoffuni_to_utf8_flags(d, uv, 0);
 #else
-       if (uv < 0x10000) {
+       if (uv < FIRST_IN_PLANE1) {
            *d++ = (U8)(( uv >> 12)         | 0xe0);
            *d++ = (U8)(((uv >>  6) & 0x3f) | 0x80);
            *d++ = (U8)(( uv        & 0x3f) | 0x80);
diff --git a/util.c b/util.c
index 4584c735bc..b470681bdd 100644
--- a/util.c
+++ b/util.c
@@ -3795,6 +3795,8 @@ Perl_mini_mktime(struct tm *ptm)
  * This algorithm also fails to handle years before A.D. 1 gracefully, but
  * that's still outside the scope for POSIX time manipulation, so I don't
  * care.
+ *
+ * - jhi
  */
 
     year = 1900 + ptm->tm_year;
@@ -3903,7 +3905,13 @@ Perl_my_strftime(pTHX_ const char *fmt, int sec, int 
min, int hour, int mday, in
 {
 #ifdef HAS_STRFTIME
 
-  /* Note that yday and wday effectively are ignored by this function, as 
mini_mktime() overwrites them */
+  /* strftime(), but with a different API so that the return value is a pointer
+   * to the formatted result (which MUST be arranged to be FREED BY THE
+   * CALLER).  This allows this function to increase the buffer size as needed,
+   * so that the caller doesn't have to worry about that.
+   *
+   * Note that yday and wday effectively are ignored by this function, as
+   * mini_mktime() overwrites them */
 
   char *buf;
   int buflen;
@@ -6096,17 +6104,17 @@ static const char* atos_parse(const char* p,
     UV uv;
 
     /* Skip trailing whitespace. */
-    while (p > start && isspace(*p)) p--;
+    while (p > start && isSPACE(*p)) p--;
     /* Now we should be at the close paren. */
     if (p == start || *p != ')')
         return NULL;
     close_paren = p;
     p--;
     /* Now we should be in the line number. */
-    if (p == start || !isdigit(*p))
+    if (p == start || !isDIGIT(*p))
         return NULL;
     /* Skip over the digits. */
-    while (p > start && isdigit(*p))
+    while (p > start && isDIGIT(*p))
         p--;
     /* Now we should be at the colon. */
     if (p == start || *p != ':')
@@ -6151,7 +6159,7 @@ static void atos_symbolize(atos_context* ctx,
      * the object name (used as "-o '%s'" ), leave since at least
      * partially the user controls it. */
     for (p = ctx->fname; *p; p++) {
-        if (*p == '\'' || iscntrl(*p)) {
+        if (*p == '\'' || isCNTRL(*p)) {
             ctx->unavail = TRUE;
             return;
         }

--
Perl5 Master Repository

Reply via email to