This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Replace an 'if' by an assert
authorKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 02:15:07 +0000 (19:15 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 02:55:58 +0000 (19:55 -0700)
This should be true if we get to here.

locale.c

index 7192916..9970ae6 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -943,6 +943,7 @@ S_emulate_setlocale(const int category,
 
             /* Find the index of the category name in our lists */
             for (i = 0; i < LC_ALL_INDEX; i++) {
+                char * individ_locale;
 
                 /* Keep going if this isn't the index.  The strnNE() avoids a
                  * Perl_form(), but would fail if ever a category name could be
@@ -961,10 +962,9 @@ S_emulate_setlocale(const int category,
                     goto ready_to_set;
                 }
 
-                if (category == LC_ALL) {
-                    char * individ_locale = Perl_form(aTHX_ "%.*s", (int) (p - s), s);
-                    emulate_setlocale(categories[i], individ_locale, i, TRUE);
-                }
+                assert(category == LC_ALL);
+                individ_locale = Perl_form(aTHX_ "%.*s", (int) (p - s), s);
+                emulate_setlocale(categories[i], individ_locale, i, TRUE);
             }
 
             s = p;