From: Perl 5 Porters Date: Mon, 9 Sep 1996 21:11:03 +0000 (+0000) Subject: perl 5.003_05: pp_sys.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cd52b7b2481ed55ef2eb5159fcf8cc2612ba2f6b;p=p5sagit%2Fp5-mst-13.2.git perl 5.003_05: pp_sys.c Clear any buffer space exposed by by read(). This is almost certainly a bug-fix. Undef and then re-define my_chsize from Perl_my_chsize to just plain chsize if this system HAS_CHSIZE. This probably only applies to SCO. This shows the perils of having internal functions with the same name as external library functions :-). Use CLK_TCK if HZ is not available. --- diff --git a/pp_sys.c b/pp_sys.c index 9d962d0..6622317 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -92,6 +92,9 @@ static int dooneliner _((char *cmd, char *filename)); #endif #ifdef HAS_CHSIZE +# ifdef my_chsize /* Probably #defined to Perl_my_chsize in embed.h */ +# undef my_chsize +# endif # define my_chsize chsize #endif @@ -1095,7 +1098,11 @@ PP(pp_sysread) if (op->op_type == OP_RECV) DIE(no_sock_func, "recv"); #endif + bufsize = SvCUR(bufsv); buffer = SvGROW(bufsv, length+offset+1); + if (offset > bufsize) { /* Zero any newly allocated space */ + Zero(buffer+bufsize, offset-bufsize, char); + } if (op->op_type == OP_SYSREAD) { length = read(PerlIO_fileno(IoIFP(io)), buffer+offset, length); } @@ -3053,8 +3060,20 @@ PP(pp_time) RETURN; } +/* XXX The POSIX name is CLK_TCK; it is to be preferred + to HZ. Probably. For now, assume that if the system + defines HZ, it does so correctly. (Will this break + on VMS?) + Probably we ought to use _sysconf(_SC_CLK_TCK), if + it's supported. --AD 9/96. +*/ + #ifndef HZ -#define HZ 60 +# ifdef CLK_TCK +# define HZ CLK_TCK +# else +# define HZ 60 +# endif #endif PP(pp_tms) @@ -3072,8 +3091,6 @@ PP(pp_tms) (void)times((tbuffer_t *)×buf); /* time.h uses different name for */ /* struct tms, though same data */ /* is returned. */ -#undef HZ -#define HZ CLK_TCK #endif PUSHs(sv_2mortal(newSVnv(((double)timesbuf.tms_utime)/HZ)));