This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Clarify warning message
authorKarl Williamson <khw@cpan.org>
Fri, 16 Mar 2018 19:57:00 +0000 (13:57 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 16 Mar 2018 20:09:42 +0000 (14:09 -0600)
When there are discrepancies in the locale and what Perl is expecting, a
warning is raised listing the problematic characters.  For \n, and \t,
they should have been displayed as mnemonics, but a required backslash
to escape things had been omitted, so they were displayed literally, so
looked just like white space.  Also, put any displayed blank in ' ' so
it won't look like the list is empty.

locale.c

index 7a0cd74..cb59929 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -1548,18 +1548,22 @@ S_new_ctype(pTHX_ const char *newctype)
                 && (isGRAPH_A(i) || isBLANK_A(i) || i == '\n'))
             {
                 bool is_bad = FALSE;
                 && (isGRAPH_A(i) || isBLANK_A(i) || i == '\n'))
             {
                 bool is_bad = FALSE;
-                char name[3] = { '\0' };
+                char name[4] = { '\0' };
 
                 /* Convert the name into a string */
 
                 /* Convert the name into a string */
-                if (isPRINT_A(i)) {
+                if (isGRAPH_A(i)) {
                     name[0] = i;
                     name[1] = '\0';
                 }
                 else if (i == '\n') {
                     name[0] = i;
                     name[1] = '\0';
                 }
                 else if (i == '\n') {
-                    my_strlcpy(name, "\n", sizeof(name));
+                    my_strlcpy(name, "\\n", sizeof(name));
+                }
+                else if (i == '\t') {
+                    my_strlcpy(name, "\\t", sizeof(name));
                 }
                 else {
                 }
                 else {
-                    my_strlcpy(name, "\t", sizeof(name));
+                    assert(i == ' ');
+                    my_strlcpy(name, "' '", sizeof(name));
                 }
 
                 /* Check each possibe class */
                 }
 
                 /* Check each possibe class */