Get rid of a few more hardcoded string lengths.
Gisle Aas [Wed, 4 Jan 2006 13:53:16 +0000 (13:53 +0000)]
p4raw-id: //depot/perl@26645

locale.c
mg.c
perl.c
perlio.c
sv.c

index 881ebd9..567a97a 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -499,23 +499,23 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
         codeset = nl_langinfo(CODESET);
 #endif
         if (codeset)
-             utf8locale = (ibcmp(codeset,  "UTF-8", 5) == 0 ||
-                           ibcmp(codeset,  "UTF8",  4) == 0);
+             utf8locale = (ibcmp(codeset, STR_WITH_LEN("UTF-8")) == 0 ||
+                           ibcmp(codeset, STR_WITH_LEN("UTF8") ) == 0);
 #if defined(USE_LOCALE)
         else { /* nl_langinfo(CODESET) is supposed to correctly
                 * interpret the locale environment variables,
                 * but just in case it fails, let's do this manually. */ 
              if (lang)
-                  utf8locale = (ibcmp(lang,     "UTF-8", 5) == 0 ||
-                                ibcmp(lang,     "UTF8",  4) == 0);
+                  utf8locale = (ibcmp(lang, STR_WITH_LEN("UTF-8")) == 0 ||
+                                ibcmp(lang, STR_WITH_LEN("UTF8") ) == 0);
 #ifdef USE_LOCALE_CTYPE
              if (curctype)
-                  utf8locale = (ibcmp(curctype,     "UTF-8", 5) == 0 ||
-                                ibcmp(curctype,     "UTF8",  4) == 0);
+                  utf8locale = (ibcmp(curctype, STR_WITH_LEN("UTF-8")) == 0 ||
+                                ibcmp(curctype, STR_WITH_LEN("UTF8") ) == 0);
 #endif
              if (lc_all)
-                  utf8locale = (ibcmp(lc_all,   "UTF-8", 5) == 0 ||
-                                ibcmp(lc_all,   "UTF8",  4) == 0);
+                  utf8locale = (ibcmp(lc_all, STR_WITH_LEN("UTF-8")) == 0 ||
+                                ibcmp(lc_all, STR_WITH_LEN("UTF8") ) == 0);
         }
 #endif /* USE_LOCALE */
         if (utf8locale)
diff --git a/mg.c b/mg.c
index 3478b41..f13dd36 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1444,7 +1444,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
         * tell whether HINT_STRICT_REFS is in force or not.
         */
        if (!strchr(s,':') && !strchr(s,'\''))
-           sv_insert(sv, 0, 0, "main::", 6);
+           sv_insert(sv, 0, 0, STR_WITH_LEN("main::"));
        if (i)
            (void)rsignal(i, PL_csighandlerp);
        else
diff --git a/perl.c b/perl.c
index cd8415c..1aff49d 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1861,7 +1861,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 
                        opts = space - pv;
                        sv_insert(opts_prog, opts, 0,
-                                 "\\n                       ", 25);
+                                 STR_WITH_LEN("\\n                       "));
                    }
 
                    sv_catpvs(opts_prog,"\\n\",");
index 95ac41d..6937b36 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1414,20 +1414,20 @@ PerlIO_layer_from_ref(pTHX_ SV *sv)
      * For any scalar type load the handler which is bundled with perl
      */
     if (SvTYPE(sv) < SVt_PVAV)
-       return PerlIO_find_layer(aTHX_ "scalar", 6, 1);
+       return PerlIO_find_layer(aTHX_ STR_WITH_LEN("scalar"), 1);
 
     /*
      * For other types allow if layer is known but don't try and load it
      */
     switch (SvTYPE(sv)) {
     case SVt_PVAV:
-       return PerlIO_find_layer(aTHX_ "Array", 5, 0);
+       return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Array"), 0);
     case SVt_PVHV:
-       return PerlIO_find_layer(aTHX_ "Hash", 4, 0);
+       return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Hash"), 0);
     case SVt_PVCV:
-       return PerlIO_find_layer(aTHX_ "Code", 4, 0);
+       return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Code"), 0);
     case SVt_PVGV:
-       return PerlIO_find_layer(aTHX_ "Glob", 4, 0);
+       return PerlIO_find_layer(aTHX_ STR_WITH_LEN("Glob"), 0);
     }
     return NULL;
 }
diff --git a/sv.c b/sv.c
index bd43352..6f296d7 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11175,7 +11175,7 @@ S_varname(pTHX_ GV *gv, const char gvtype, PADOFFSET targ,
        Perl_sv_catpvf(aTHX_ name, "[%"IVdf"]", (IV)aindex);
     }
     else if (subscript_type == FUV_SUBSCRIPT_WITHIN)
-       sv_insert(name, 0, 0,  "within ", 7);
+       sv_insert(name, 0, 0,  STR_WITH_LEN("within "));
 
     return name;
 }