summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-09-09 21:11:03 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1996-09-09 21:11:03 +0000
commitcd52b7b2481ed55ef2eb5159fcf8cc2612ba2f6b (patch)
tree5824f802a20ac8ef8d528f1ad7910945a9bcaaba /pp_sys.c
parente79b05116c7f6dd4a9d984471401ae61fd054c7d (diff)
downloadperl-cd52b7b2481ed55ef2eb5159fcf8cc2612ba2f6b.tar.gz
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.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 9d962d0a71..66223178eb 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 *)&timesbuf); /* 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)));