From: Malcolm Beattie Date: Fri, 3 Oct 1997 17:12:33 +0000 (+0000) Subject: Remove last traces of "tokenbuf as temp buffer" and removed it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=968277801164b16eb55f9f8fd3162dc3b6226110;p=p5sagit%2Fp5-mst-13.2.git Remove last traces of "tokenbuf as temp buffer" and removed it from struct thread. Added missing thr->Tfoo defines for statbuf and timesbuf and removed unused Tbuf field. p4raw-id: //depot/perl@106 --- diff --git a/doio.c b/doio.c index d905af1..bb0ac47 100644 --- a/doio.c +++ b/doio.c @@ -283,6 +283,7 @@ PerlIO *supplied_fp; } if (IoTYPE(io) && IoTYPE(io) != '|' && IoTYPE(io) != '-') { + dTHR; if (Fstat(PerlIO_fileno(fp),&statbuf) < 0) { (void)PerlIO_close(fp); goto say_false; @@ -297,8 +298,9 @@ PerlIO *supplied_fp; !statbuf.st_mode #endif ) { - Sock_size_t buflen = sizeof tokenbuf; - if (getsockname(PerlIO_fileno(fp), (struct sockaddr *)tokenbuf, + char tmpbuf[256]; + Sock_size_t buflen = sizeof tmpbuf; + if (getsockname(PerlIO_fileno(fp), (struct sockaddr *)tmpbuf, &buflen) >= 0 || errno != ENOTSOCK) IoTYPE(io) = 's'; /* some OS's return 0 on fstat()ed socket */ @@ -340,6 +342,7 @@ PerlIO *supplied_fp; #endif IoIFP(io) = fp; if (writing) { + dTHR; if (IoTYPE(io) == 's' || (IoTYPE(io) == '>' && S_ISCHR(statbuf.st_mode)) ) { if (!(IoOFP(io) = PerlIO_fdopen(PerlIO_fileno(fp),"w"))) { diff --git a/mg.c b/mg.c index db8356f..ad0c0da 100644 --- a/mg.c +++ b/mg.c @@ -629,13 +629,14 @@ MAGIC* mg; char *strend = s + len; while (s < strend) { + char tmpbuf[256]; struct stat st; - s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, + s = delimcpy(tmpbuf, tmpbuf + sizeof tmpbuf, s, strend, ':', &i); s++; - if (i >= sizeof tokenbuf /* too long -- assume the worst */ - || *tokenbuf != '/' - || (Stat(tokenbuf, &st) == 0 && (st.st_mode & 2)) ) { + if (i >= sizeof tmpbuf /* too long -- assume the worst */ + || *tmpbuf != '/' + || (Stat(tmpbuf, &st) == 0 && (st.st_mode & 2)) ) { MgTAINTEDDIR_on(mg); return 0; } diff --git a/perl.c b/perl.c index f08def4..d896801 100644 --- a/perl.c +++ b/perl.c @@ -2205,6 +2205,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n"); #else /* !DOSUID */ if (euid != uid || egid != gid) { /* (suidperl doesn't exist, in fact) */ #ifndef SETUID_SCRIPTS_ARE_SECURE_NOW + dTHR; Fstat(PerlIO_fileno(rsfp),&statbuf); /* may be either wrapped or real suid */ if ((euid != uid && euid == statbuf.st_uid && statbuf.st_mode & S_ISUID) || diff --git a/pp_sys.c b/pp_sys.c index 97b86e3..7cded50 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -178,7 +178,8 @@ PP(pp_backtick) fp = my_popen(tmps, "r"); if (fp) { if (gimme == G_VOID) { - while (PerlIO_read(fp, tokenbuf, sizeof tokenbuf) > 0) + char tmpbuf[256]; + while (PerlIO_read(fp, tmpbuf, sizeof tmpbuf) > 0) /*SUPPRESS 530*/ ; } diff --git a/sv.c b/sv.c index 0f5c107..ab08483 100644 --- a/sv.c +++ b/sv.c @@ -965,7 +965,7 @@ register SV *sv; case SVt_NULL: sv_catpv(t, "UNDEF"); - return tokenbuf; + goto finish; case SVt_IV: sv_catpv(t, "IV"); break; @@ -1609,6 +1609,7 @@ STRLEN *lp; register char *s; int olderrno; SV *tsv; + char tmpbuf[64]; /* Must fit sprintf/Gconvert of longest IV/NV */ if (!sv) { *lp = 0; @@ -1621,13 +1622,13 @@ STRLEN *lp; return SvPVX(sv); } if (SvIOKp(sv)) { - (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv)); + (void)sprintf(tmpbuf,"%ld",(long)SvIVX(sv)); tsv = Nullsv; goto tokensave; } if (SvNOKp(sv)) { SET_NUMERIC_STANDARD(); - Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf); + Gconvert(SvNVX(sv), DBL_DIG, 0, tmpbuf); tsv = Nullsv; goto tokensave; } @@ -1683,12 +1684,12 @@ STRLEN *lp; if (SvREADONLY(sv)) { if (SvNOKp(sv)) { SET_NUMERIC_STANDARD(); - Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf); + Gconvert(SvNVX(sv), DBL_DIG, 0, tmpbuf); tsv = Nullsv; goto tokensave; } if (SvIOKp(sv)) { - (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv)); + (void)sprintf(tmpbuf,"%ld",(long)SvIVX(sv)); tsv = Nullsv; goto tokensave; } @@ -1753,7 +1754,7 @@ STRLEN *lp; tokensaveref: if (!tsv) - tsv = newSVpv(tokenbuf, 0); + tsv = newSVpv(tmpbuf, 0); sv_2mortal(tsv); *lp = SvCUR(tsv); return SvPVX(tsv); @@ -1768,8 +1769,8 @@ STRLEN *lp; len = SvCUR(tsv); } else { - t = tokenbuf; - len = strlen(tokenbuf); + t = tmpbuf; + len = strlen(tmpbuf); } #ifdef FIXNEGATIVEZERO if (len == 2 && t[0] == '-' && t[1] == '0') { diff --git a/thread.h b/thread.h index f7ca06c..5e5bebd 100644 --- a/thread.h +++ b/thread.h @@ -115,8 +115,6 @@ struct thread { SV * TSv; XPV * TXpv; - char Tbuf[2048]; /* should be a global locked by a mutex */ - char Ttokenbuf[256]; /* should be a global locked by a mutex */ struct stat Tstatbuf; struct tms Ttimesbuf; @@ -225,6 +223,8 @@ typedef struct condpair { #undef curpad #undef Sv #undef Xpv +#undef statbuf +#undef timesbuf #undef top_env #undef runlevel #undef in_eval @@ -270,6 +270,8 @@ typedef struct condpair { #define curpad (thr->Tcurpad) #define Sv (thr->TSv) #define Xpv (thr->TXpv) +#define statbuf (thr->Tstatbuf) +#define timesbuf (thr->Ttimesbuf) #define defstash (thr->Tdefstash) #define curstash (thr->Tcurstash)