This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ext/POSIX/POSIX.xs: Convert do whiles into whiles
authorKarl Williamson <khw@cpan.org>
Mon, 9 Mar 2015 03:16:16 +0000 (21:16 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 9 Mar 2015 15:37:08 +0000 (09:37 -0600)
I don't know why these are do { ] while's, but with the correct
combination of compile flags (such as -DNO_LOCALE), and/or perhaps
platform, one or the other could be called the first time with nulls, so
they need to be straight while{}s to avoid segfaults.

ext/POSIX/POSIX.xs
ext/POSIX/lib/POSIX.pm

index b1118bd..26ca464 100644 (file)
@@ -2011,7 +2011,7 @@ localeconv()
            const struct lconv_offset *integers = lconv_integers;
            const char *ptr = (const char *) lcbuf;
 
-           do {
+           while (strings->name) {
                 /* This string may be controlled by either LC_NUMERIC, or
                  * LC_MONETARY */
                 bool is_utf8_locale
@@ -2042,16 +2042,18 @@ localeconv()
                                         && ! is_invariant_string((U8 *) value, 0)
                                         && is_utf8_string((U8 *) value, 0)),
                         0);
-                  }
-           } while ((++strings)->name);
+                }
+                strings++;
+           }
 
-           do {
+           while (integers->name) {
                const char value = *((const char *)(ptr + integers->offset));
 
                if (value != CHAR_MAX)
                    (void) hv_store(RETVAL, integers->name,
                                    strlen(integers->name), newSViv(value), 0);
-           } while ((++integers)->name);
+                integers++;
+            }
        }
         RESTORE_NUMERIC_STANDARD();
 #endif  /* HAS_LOCALECONV */
index a825178..2a78f19 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 
 our ($AUTOLOAD, %SIGRT);
 
-our $VERSION = '1.51';
+our $VERSION = '1.52';
 
 require XSLoader;