This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
handle_names_wildcard: better avoid compiler warning
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Thu, 30 Apr 2020 16:56:31 +0000 (17:56 +0100)
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Thu, 30 Apr 2020 16:56:31 +0000 (17:56 +0100)
instead of casting away the const from a string literal,
declare the variable as a pointer to const char

regcomp.c

index a706a91..04e81ce 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -25027,7 +25027,7 @@ S_handle_names_wildcard(pTHX_ const char * wname, /* wildcard name to match */
     SV * empty;                 /* For matching zero length names */
     SV * must_sv;               /* Contains the substring, if any, that must be
                                    in a name for the subpattern to match */
-    char * must;                /* The PV of 'must' */
+    const char * must;          /* The PV of 'must' */
     STRLEN must_len;            /* And its length */
     SV * syllable_name = NULL;  /* For Hangul syllables */
     const char hangul_prefix[] = "HANGUL SYLLABLE ";
@@ -25101,7 +25101,7 @@ S_handle_names_wildcard(pTHX_ const char * wname, /* wildcard name to match */
         must = SvPV(must_sv, must_len);
     }
     else {
-        must = (char *)"";
+        must = "";
         must_len = 0;
     }