This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Module::Pluggable::Object::search_paths portability update prompted by
[perl5.git] / gv.c
diff --git a/gv.c b/gv.c
index e1f1299..e03521e 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -104,31 +104,39 @@ Perl_gv_IOadd(pTHX_ register GV *gv)
 GV *
 Perl_gv_fetchfile(pTHX_ const char *name)
 {
+    return gv_fetchfile_flags(name, strlen(name), 0);
+}
+
+GV *
+Perl_gv_fetchfile_flags(pTHX_ const char *const name, const STRLEN namelen,
+                       const U32 flags)
+{
     dVAR;
     char smallbuf[128];
     char *tmpbuf;
-    STRLEN tmplen;
+    const STRLEN tmplen = namelen + 2;
     GV *gv;
 
+    PERL_UNUSED_ARG(flags);
+
     if (!PL_defstash)
        return NULL;
 
-    tmplen = strlen(name) + 2;
-    if (tmplen < sizeof smallbuf)
+    if (tmplen <= sizeof smallbuf)
        tmpbuf = smallbuf;
     else
-       Newx(tmpbuf, tmplen + 1, char);
+       Newx(tmpbuf, tmplen, char);
     /* This is where the debugger's %{"::_<$filename"} hash is created */
     tmpbuf[0] = '_';
     tmpbuf[1] = '<';
-    memcpy(tmpbuf + 2, name, tmplen - 1);
+    memcpy(tmpbuf + 2, name, namelen);
     gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, TRUE);
     if (!isGV(gv)) {
        gv_init(gv, PL_defstash, tmpbuf, tmplen, FALSE);
 #ifdef PERL_DONT_CREATE_GVSV
-       GvSV(gv) = newSVpvn(name, tmplen - 2);
+       GvSV(gv) = newSVpvn(name, namelen);
 #else
-       sv_setpvn(GvSV(gv), name, tmplen - 2);
+       sv_setpvn(GvSV(gv), name, namelen);
 #endif
        if (PERLDB_LINE)
            hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile);
@@ -247,7 +255,6 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
            if (exported_constant)
                GvIMPORTED_CV_on(gv);
        } else {
-           /* XXX unsafe for threads if eval_owner isn't held */
            (void) start_subparse(0,0); /* Create empty CV in compcv. */
            GvCV(gv) = PL_compcv;
        }
@@ -709,7 +716,7 @@ S_require_tie_mod(pTHX_ GV *gv, const char *varpv, SV* namesv, const char *methp
 =for apidoc gv_stashpv
 
 Returns a pointer to the stash for a specified package.  Uses C<strlen> to
-determine the length of C<name, then calls C<gv_stashpvn()>.
+determine the length of C<name>, then calls C<gv_stashpvn()>.
 
 =cut
 */
@@ -742,7 +749,7 @@ Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags)
     HV *stash;
     GV *tmpgv;
 
-    if (namelen + 2 < sizeof smallbuf)
+    if (namelen + 2 <= sizeof smallbuf)
        tmpbuf = smallbuf;
     else
        Newx(tmpbuf, namelen + 2, char);
@@ -834,7 +841,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
                char smallbuf[128];
                char *tmpbuf;
 
-               if (len + 2 < (I32)sizeof (smallbuf))
+               if (len + 2 <= (I32)sizeof (smallbuf))
                    tmpbuf = smallbuf;
                else
                    Newx(tmpbuf, len+2, char);
@@ -1347,9 +1354,7 @@ Perl_newIO(pTHX)
 {
     dVAR;
     GV *iogv;
-    IO * const io = (IO*)newSV(0);
-
-    sv_upgrade((SV *)io,SVt_PVIO);
+    IO * const io = (IO*)newSV_type(SVt_PVIO);
     /* This used to read SvREFCNT(io) = 1;
        It's not clear why the reference count needed an explicit reset. NWC
     */
@@ -1866,6 +1871,19 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags)
     } else {
     not_found:                 /* No method found, either report or croak */
       switch (method) {
+        case lt_amg:
+        case le_amg:
+        case gt_amg:
+        case ge_amg:
+        case eq_amg:
+        case ne_amg:
+        case slt_amg:
+        case sle_amg:
+        case sgt_amg:
+        case sge_amg:
+        case seq_amg:
+        case sne_amg:
+          postpr = 0; break;
         case to_sv_amg:
         case to_av_amg:
         case to_hv_amg: