Remove the strlen in doopen_pm() by passing in the length. (As we know
Nicholas Clark [Tue, 9 Oct 2007 20:06:57 +0000 (20:06 +0000)]
it already in the caller). Remove the unchanging mode parameter from
doopen_pm() and check_type_and_open(), as it's always PERL_SCRIPT_MODE.

p4raw-id: //depot/perl@32086

embed.fnc
embed.h
pp_ctl.c
proto.h

index 0e6e3f7..6030e5c 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1323,8 +1323,8 @@ sR        |I32    |dopoptosub_at  |NN const PERL_CONTEXT* cxstk|I32 startingblock
 sR     |I32    |dopoptowhen    |I32 startingblock
 s      |void   |save_lines     |NULLOK AV *array|NN SV *sv
 s      |bool   |doeval         |int gimme|NULLOK OP** startop|NULLOK CV* outside|U32 seq
-sR     |PerlIO *|check_type_and_open|NN const char *name|NN const char *mode
-sR     |PerlIO *|doopen_pm     |NN const char *name|NN const char *mode
+sR     |PerlIO *|check_type_and_open|NN const char *name
+sR     |PerlIO *|doopen_pm     |NN const char *name|const STRLEN namelen
 sRn    |bool   |path_is_absolute|NN const char *name
 sR     |I32    |run_user_filter|int idx|NN SV *buf_sv|int maxlen
 sR     |PMOP*  |make_matcher   |NN regexp* re
diff --git a/embed.h b/embed.h
index 8f86f3e..418f794 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define dopoptowhen(a)         S_dopoptowhen(aTHX_ a)
 #define save_lines(a,b)                S_save_lines(aTHX_ a,b)
 #define doeval(a,b,c,d)                S_doeval(aTHX_ a,b,c,d)
-#define check_type_and_open(a,b)       S_check_type_and_open(aTHX_ a,b)
+#define check_type_and_open(a) S_check_type_and_open(aTHX_ a)
 #define doopen_pm(a,b)         S_doopen_pm(aTHX_ a,b)
 #define path_is_absolute       S_path_is_absolute
 #define run_user_filter(a,b,c) S_run_user_filter(aTHX_ a,b,c)
index af40061..d925171 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3006,7 +3006,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
 }
 
 STATIC PerlIO *
-S_check_type_and_open(pTHX_ const char *name, const char *mode)
+S_check_type_and_open(pTHX_ const char *name)
 {
     Stat_t st;
     const int st_rc = PerlLIO_stat(name, &st);
@@ -3015,14 +3015,13 @@ S_check_type_and_open(pTHX_ const char *name, const char *mode)
        return NULL;
     }
 
-    return PerlIO_open(name, mode);
+    return PerlIO_open(name, PERL_SCRIPT_MODE);
 }
 
 STATIC PerlIO *
-S_doopen_pm(pTHX_ const char *name, const char *mode)
+S_doopen_pm(pTHX_ const char *name, const STRLEN namelen)
 {
 #ifndef PERL_DISABLE_PMC
-    const STRLEN namelen = strlen(name);
     PerlIO *fp;
 
     if (namelen > 3 && strEQ(name + namelen - 3, ".pm")) {
@@ -3035,19 +3034,19 @@ S_doopen_pm(pTHX_ const char *name, const char *mode)
        pmc[namelen + 1] = '\0';
 
        if (PerlLIO_stat(pmc, &pmcstat) < 0) {
-           fp = check_type_and_open(name, mode);
+           fp = check_type_and_open(name);
        }
        else {
-           fp = check_type_and_open(pmc, mode);
+           fp = check_type_and_open(pmc);
        }
        SvREFCNT_dec(pmcsv);
     }
     else {
-       fp = check_type_and_open(name, mode);
+       fp = check_type_and_open(name);
     }
     return fp;
 #else
-    return check_type_and_open(name, mode);
+    return check_type_and_open(name);
 #endif /* !PERL_DISABLE_PMC */
 }
 
@@ -3202,7 +3201,7 @@ PP(pp_require)
 
     if (path_is_absolute(name)) {
        tryname = name;
-       tryrsfp = doopen_pm(name,PERL_SCRIPT_MODE);
+       tryrsfp = doopen_pm(name, len);
     }
 #ifdef MACOS_TRADITIONAL
     if (!tryrsfp) {
@@ -3211,7 +3210,7 @@ PP(pp_require)
        MacPerl_CanonDir(name, newname, 1);
        if (path_is_absolute(newname)) {
            tryname = newname;
-           tryrsfp = doopen_pm(newname,PERL_SCRIPT_MODE);
+           tryrsfp = doopen_pm(newname, strlen(newname));
        }
     }
 #endif
@@ -3386,7 +3385,7 @@ PP(pp_require)
 #endif
                    TAINT_PROPER("require");
                    tryname = SvPVX_const(namesv);
-                   tryrsfp = doopen_pm(tryname, PERL_SCRIPT_MODE);
+                   tryrsfp = doopen_pm(tryname, SvCUR(namesv));
                    if (tryrsfp) {
                        if (tryname[0] == '.' && tryname[1] == '/')
                            tryname += 2;
diff --git a/proto.h b/proto.h
index cac4e52..c96c1d3 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -3538,15 +3538,13 @@ STATIC void     S_save_lines(pTHX_ AV *array, SV *sv)
                        __attribute__nonnull__(pTHX_2);
 
 STATIC bool    S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq);
-STATIC PerlIO *        S_check_type_and_open(pTHX_ const char *name, const char *mode)
+STATIC PerlIO *        S_check_type_and_open(pTHX_ const char *name)
                        __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1)
-                       __attribute__nonnull__(pTHX_2);
+                       __attribute__nonnull__(pTHX_1);
 
-STATIC PerlIO *        S_doopen_pm(pTHX_ const char *name, const char *mode)
+STATIC PerlIO *        S_doopen_pm(pTHX_ const char *name, const STRLEN namelen)
                        __attribute__warn_unused_result__
-                       __attribute__nonnull__(pTHX_1)
-                       __attribute__nonnull__(pTHX_2);
+                       __attribute__nonnull__(pTHX_1);
 
 STATIC bool    S_path_is_absolute(const char *name)
                        __attribute__warn_unused_result__