Skip to content

Commit

Permalink
patchlevel up to 5.004_70, various tweaks
Browse files Browse the repository at this point in the history
 * 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
  • Loading branch information
Gurusamy Sarathy committed Jul 5, 1998
1 parent 1116284 commit 7231175
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 74 deletions.
3 changes: 2 additions & 1 deletion av.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -620,6 +620,7 @@ avhv_keys(AV *av)
}
}
croak("Can't coerce array into hash");
return Nullhv;
}

SV**
Expand Down
62 changes: 33 additions & 29 deletions hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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--;
}
}
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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--;
}
}
Expand Down
2 changes: 2 additions & 0 deletions objpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion patchlevel.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 9 additions & 10 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions pp_hot.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,9 @@ PP(pp_match)
/*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;

Expand Down Expand Up @@ -970,7 +972,9 @@ PP(pp_match)
}

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)
Expand Down
2 changes: 1 addition & 1 deletion proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...));
Expand Down
2 changes: 1 addition & 1 deletion regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ regexec_flags(register regexp *prog, char *stringarg, register char *strend, cha
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. */
Expand Down
8 changes: 5 additions & 3 deletions regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion toke.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 6 additions & 13 deletions win32/perlhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -57,27 +50,27 @@ class CPerlDir : public IPerlDir
};
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);
};
};

Expand Down
12 changes: 0 additions & 12 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7231175

Please sign in to comment.