This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
patchlevel up to 5.004_70, various tweaks
authorGurusamy Sarathy <gsar@cpan.org>
Sun, 5 Jul 1998 00:35:27 +0000 (00:35 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 5 Jul 1998 00:35:27 +0000 (00:35 +0000)
 * fix taint problems due to maintbranch regression
 * PERL_OBJECT now builds again
 * deal with C++ strong-typing problems in hv.c
 * fix mismatch in "reserved word" diagnostic

p4raw-id: //depot/perl@1311

12 files changed:
av.c
hv.c
objpp.h
patchlevel.h
pp_ctl.c
pp_hot.c
proto.h
regexec.c
regexp.h
toke.c
win32/perlhost.h
win32/win32.c

diff --git a/av.c b/av.c
index 2e46053..b69dcf2 100644 (file)
--- a/av.c
+++ b/av.c
@@ -596,7 +596,7 @@ av_fill(register AV *av, I32 fill)
  * hash keys to array indices.
  */
 
-static I32
+STATIC I32
 avhv_index_sv(SV* sv)
 {
     I32 index = SvIV(sv);
@@ -620,6 +620,7 @@ avhv_keys(AV *av)
        }
     }
     croak("Can't coerce array into hash");
+    return Nullhv;
 }
 
 SV**
diff --git a/hv.c b/hv.c
index 918640e..4f5642f 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -299,7 +299,7 @@ hv_store(HV *hv, char *key, U32 klen, SV *val, register U32 hash)
        PERL_HASH(hash, key, klen);
 
     if (!xhv->xhv_array)
-       Newz(505, xhv->xhv_array, sizeof(HE**) * (xhv->xhv_max + 1), char);
+       Newz(505, xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
 
     oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
     i = 1;
@@ -380,7 +380,7 @@ hv_store_ent(HV *hv, SV *keysv, SV *val, register U32 hash)
        PERL_HASH(hash, key, klen);
 
     if (!xhv->xhv_array)
-       Newz(505, xhv->xhv_array, sizeof(HE**) * (xhv->xhv_max + 1), char);
+       Newz(505, xhv->xhv_array, sizeof(HE*) * (xhv->xhv_max + 1), char);
 
     oentry = &((HE**)xhv->xhv_array)[hash & (I32) xhv->xhv_max];
     i = 1;
@@ -665,14 +665,15 @@ hsplit(HV *hv)
     I32 oldsize = (I32) xhv->xhv_max + 1; /* sic(k) */
     register I32 newsize = oldsize * 2;
     register I32 i;
-    register HE **a = (HE**)xhv->xhv_array;
-    register HE **b;
+    register char *a = xhv->xhv_array;
+    register HE **aep;
+    register HE **bep;
     register HE *entry;
     register HE **oentry;
 
     nomemok = TRUE;
 #if defined(STRANGE_MALLOC) || defined(MYMALLOC)
-    Renew(a, newsize, HE*);
+    Renew(a, newsize * sizeof(HE*), char);
     if (!a) {
       nomemok = FALSE;
       return;
@@ -684,7 +685,7 @@ hsplit(HV *hv)
       nomemok = FALSE;
       return;
     }
-    Copy(xhv->xhv_array, a, oldsize, HE*);
+    Copy(xhv->xhv_array, a, oldsize * sizeof(HE*), char);
     if (oldsize >= 64) {
        offer_nice_chunk(xhv->xhv_array,
                         oldsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD);
@@ -694,27 +695,28 @@ hsplit(HV *hv)
 #endif
 
     nomemok = FALSE;
-    Zero(&a[oldsize], oldsize, HE*);           /* zero 2nd half*/
+    Zero(&a[oldsize * sizeof(HE*)], (newsize-oldsize) * sizeof(HE*), char);    /* zero 2nd half*/
     xhv->xhv_max = --newsize;
-    xhv->xhv_array = (char*)a;
+    xhv->xhv_array = a;
+    aep = (HE**)a;
 
-    for (i=0; i<oldsize; i++,a++) {
-       if (!*a)                                /* non-existent */
+    for (i=0; i<oldsize; i++,aep++) {
+       if (!*aep)                              /* non-existent */
            continue;
-       b = a+oldsize;
-       for (oentry = a, entry = *a; entry; entry = *oentry) {
+       bep = aep+oldsize;
+       for (oentry = aep, entry = *aep; entry; entry = *oentry) {
            if ((HeHASH(entry) & newsize) != i) {
                *oentry = HeNEXT(entry);
-               HeNEXT(entry) = *b;
-               if (!*b)
+               HeNEXT(entry) = *bep;
+               if (!*bep)
                    xhv->xhv_fill++;
-               *b = entry;
+               *bep = entry;
                continue;
            }
            else
                oentry = &HeNEXT(entry);
        }
-       if (!*a)                                /* everything moved */
+       if (!*aep)                              /* everything moved */
            xhv->xhv_fill--;
     }
 }
@@ -727,7 +729,8 @@ hv_ksplit(HV *hv, IV newmax)
     register I32 newsize;
     register I32 i;
     register I32 j;
-    register HE **a;
+    register char *a;
+    register HE **aep;
     register HE *entry;
     register HE **oentry;
 
@@ -742,11 +745,11 @@ hv_ksplit(HV *hv, IV newmax)
     if (newsize < newmax)
        return;                                 /* overflow detection */
 
-    a = (HE**)xhv->xhv_array;
+    a = xhv->xhv_array;
     if (a) {
        nomemok = TRUE;
 #if defined(STRANGE_MALLOC) || defined(MYMALLOC)
-       Renew(a, newsize, HE*);
+       Renew(a, newsize * sizeof(HE*), char);
         if (!a) {
          nomemok = FALSE;
          return;
@@ -757,7 +760,7 @@ hv_ksplit(HV *hv, IV newmax)
          nomemok = FALSE;
          return;
        }
-       Copy(xhv->xhv_array, a, oldsize, HE*);
+       Copy(xhv->xhv_array, a, oldsize * sizeof(HE*), char);
        if (oldsize >= 64) {
            offer_nice_chunk(xhv->xhv_array,
                             oldsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD);
@@ -766,36 +769,37 @@ hv_ksplit(HV *hv, IV newmax)
            Safefree(xhv->xhv_array);
 #endif
        nomemok = FALSE;
-       Zero(&a[oldsize], newsize-oldsize, HE*); /* zero 2nd half*/
+       Zero(&a[oldsize * sizeof(HE*)], (newsize-oldsize) * sizeof(HE*), char); /* zero 2nd half*/
     }
     else {
 #if defined(STRANGE_MALLOC) || defined(MYMALLOC)
-       Newz(0, a, newsize, HE*);
+       Newz(0, a, newsize * sizeof(HE*), char);
 #else
        Newz(0, a, newsize * sizeof(HE*) * 2 - MALLOC_OVERHEAD, char);
 #endif
     }
     xhv->xhv_max = --newsize;
-    xhv->xhv_array = (char*)a;
+    xhv->xhv_array = a;
     if (!xhv->xhv_fill)                                /* skip rest if no entries */
        return;
 
-    for (i=0; i<oldsize; i++,a++) {
-       if (!*a)                                /* non-existent */
+    aep = (HE**)a;
+    for (i=0; i<oldsize; i++,aep++) {
+       if (!*aep)                              /* non-existent */
            continue;
-       for (oentry = a, entry = *a; entry; entry = *oentry) {
+       for (oentry = aep, entry = *aep; entry; entry = *oentry) {
            if ((j = (HeHASH(entry) & newsize)) != i) {
                j -= i;
                *oentry = HeNEXT(entry);
-               if (!(HeNEXT(entry) = a[j]))
+               if (!(HeNEXT(entry) = aep[j]))
                    xhv->xhv_fill++;
-               a[j] = entry;
+               aep[j] = entry;
                continue;
            }
            else
                oentry = &HeNEXT(entry);
        }
-       if (!*a)                                /* everything moved */
+       if (!*aep)                              /* everything moved */
            xhv->xhv_fill--;
     }
 }
diff --git a/objpp.h b/objpp.h
index ba12c25..469fefc 100644 (file)
--- a/objpp.h
+++ b/objpp.h
@@ -55,6 +55,8 @@
 #define avhv_fetch_ent    CPerlObj::Perl_avhv_fetch_ent
 #undef  avhv_exists_ent
 #define avhv_exists_ent   CPerlObj::Perl_avhv_exists_ent
+#undef  avhv_index_sv
+#define avhv_index_sv     CPerlObj::avhv_index_sv
 #undef  avhv_iternext
 #define avhv_iternext     CPerlObj::Perl_avhv_iternext
 #undef  avhv_iterval
index a61ebda..de4e8f5 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __PATCHLEVEL_H_INCLUDED__
 #define PATCHLEVEL 4
-#define SUBVERSION 69
+#define SUBVERSION 70
 
 /*
        local_patches -- list of locally applied less-than-subversion patches.
index f121b7e..96e852e 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -90,15 +90,6 @@ PP(pp_regcomp)
     else {
        t = SvPV(tmpstr, len);
 
-#ifndef INCOMPLETE_TAINTS
-       if (tainting) {
-           if (tainted)
-               pm->op_pmdynflags |= PMdf_TAINTED;
-           else
-               pm->op_pmdynflags &= ~PMdf_TAINTED;
-       }
-#endif
-
        /* Check against the last compiled regexp. */
        if (!pm->op_pmregexp || !pm->op_pmregexp->precomp ||
            pm->op_pmregexp->prelen != len ||
@@ -114,6 +105,15 @@ PP(pp_regcomp)
        }
     }
 
+#ifndef INCOMPLETE_TAINTS
+    if (tainting) {
+       if (tainted)
+           pm->op_pmdynflags |= PMdf_TAINTED;
+       else
+           pm->op_pmdynflags &= ~PMdf_TAINTED;
+    }
+#endif
+
     if (!pm->op_pmregexp->prelen && curpm)
        pm = curpm;
     else if (strEQ("\\s+", pm->op_pmregexp->precomp))
@@ -155,7 +155,6 @@ PP(pp_substcont)
            SV *targ = cx->sb_targ;
            sv_catpvn(dstr, s, cx->sb_strend - s);
 
-           TAINT_IF(cx->sb_rxtainted || RX_MATCH_TAINTED(rx));
            cx->sb_rxtainted |= RX_MATCH_TAINTED(rx);
 
            (void)SvOOK_off(targ);
index da2a41f..8e3bf70 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -917,7 +917,9 @@ play_it_again:
     /*NOTREACHED*/
 
   gotcha:
-    RX_MATCH_TAINTED_SET(rx, rxtainted);
+    if (rxtainted)
+       RX_MATCH_TAINTED_on(rx);
+    TAINT_IF(RX_MATCH_TAINTED(rx));
     if (gimme == G_ARRAY) {
        I32 iters, i, len;
 
@@ -970,7 +972,9 @@ play_it_again:
     }
 
 yup:                                   /* Confirmed by check_substr */
-    RX_MATCH_TAINTED_SET(rx, rxtainted);
+    if (rxtainted)
+       RX_MATCH_TAINTED_on(rx);
+    TAINT_IF(RX_MATCH_TAINTED(rx));
     ++BmUSEFUL(rx->check_substr);
     curpm = pm;
     if (pm->op_pmflags & PMf_ONCE)
diff --git a/proto.h b/proto.h
index 0da072e..a74dc60 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -660,7 +660,7 @@ void del_xrv _((XRV* p));
 void sv_mortalgrow _((void));
 void sv_unglob _((SV* sv));
 void sv_check_thinkfirst _((SV *sv));
-
+I32 avhv_index_sv _((SV* sv));
 
 void sv_catpv_mg _((SV *sv, char *ptr));
 void sv_catpvf_mg _((SV *sv, const char* pat, ...));
index d5d9461..6efc93c 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -610,7 +610,7 @@ got_it:
     strend += dontbother;      /* uncheat */
     prog->subbeg = strbeg;
     prog->subend = strend;
-    RX_MATCH_TAINTED_SET(prog, reg_flags & RF_tainted);
+    RX_MATCH_TAINTED_set(prog, reg_flags & RF_tainted);
 
     /* make sure $`, $&, $', and $digit will work later */
     if (strbeg != prog->subbase) {     /* second+ //g match.  */
index f1301d9..a123efe 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -90,9 +90,11 @@ typedef struct regexp {
 #define ROPT_TAINTED_SEEN      0x8000
 
 #define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN)
-#define RX_MATCH_TAINTED_SET(prog, t) ((t) \
-                                      ? ((prog)->reganch |= ROPT_TAINTED_SEEN) \
-                                      : ((prog)->reganch &= ~ROPT_TAINTED_SEEN))
+#define RX_MATCH_TAINTED_on(prog) ((prog)->reganch |= ROPT_TAINTED_SEEN)
+#define RX_MATCH_TAINTED_off(prog) ((prog)->reganch &= ~ROPT_TAINTED_SEEN)
+#define RX_MATCH_TAINTED_set(prog, t) ((t) \
+                                      ? RX_MATCH_TAINTED_on(prog) \
+                                      : RX_MATCH_TAINTED_off(prog))
 
 #define REXEC_COPY_STR 1               /* Need to copy the string. */
 #define REXEC_CHECKED  2               /* check_substr already checked. */
diff --git a/toke.c b/toke.c
index 27571e4..65480b4 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -4399,7 +4399,7 @@ keyword(register char *d, I32 len)
        case 3:
            if (strEQ(d,"ord"))                 return -KEY_ord;
            if (strEQ(d,"oct"))                 return -KEY_oct;
-           if (strEQ(d,"our")) { deprecate("reserved keyword \"our\"");
+           if (strEQ(d,"our")) { deprecate("reserved word \"our\"");
                                                return 0;}
            break;
        case 4:
index a4c2e3c..10abef9 100644 (file)
@@ -32,13 +32,6 @@ extern CPerlObj *pPerl;
        err = errno;\
     return ret;
 
-extern int             g_closedir(DIR *dirp);
-extern DIR *           g_opendir(char *filename);
-extern struct direct * g_readdir(DIR *dirp);
-extern void            g_rewinddir(DIR *dirp);
-extern void            g_seekdir(DIR *dirp, long loc);
-extern long            g_telldir(DIR *dirp);
-
 class CPerlDir : public IPerlDir
 {
 public:
@@ -57,27 +50,27 @@ public:
     };
     virtual int Close(DIR *dirp, int &err)
     {
-       return g_closedir(dirp);
+       return win32_closedir(dirp);
     };
     virtual DIR *Open(char *filename, int &err)
     {
-       return g_opendir(filename);
+       return win32_opendir(filename);
     };
     virtual struct direct *Read(DIR *dirp, int &err)
     {
-       return g_readdir(dirp);
+       return win32_readdir(dirp);
     };
     virtual void Rewind(DIR *dirp, int &err)
     {
-       g_rewinddir(dirp);
+       win32_rewinddir(dirp);
     };
     virtual void Seek(DIR *dirp, long loc, int &err)
     {
-       g_seekdir(dirp, loc);
+       win32_seekdir(dirp, loc);
     };
     virtual long Tell(DIR *dirp, int &err)
     {
-       return g_telldir(dirp);
+       return win32_telldir(dirp);
     };
 };
 
index 03552de..ef59a8f 100644 (file)
@@ -87,18 +87,6 @@ int _CRT_glob = 0;
 #define do_spawn g_do_spawn
 #undef do_exec
 #define do_exec g_do_exec
-#undef opendir
-#define opendir g_opendir
-#undef readdir
-#define readdir g_readdir
-#undef telldir
-#define telldir g_telldir
-#undef seekdir
-#define seekdir g_seekdir
-#undef rewinddir
-#define rewinddir g_rewinddir
-#undef closedir
-#define closedir g_closedir
 #undef getlogin
 #define getlogin g_getlogin
 #endif