From: Robert Spier Date: Sat, 26 May 2001 20:05:23 +0000 (-0400) Subject: [PATCH] [ID 19991013.005] utime undef, undef, @files X-Git-Tag: perl-5.7.2~972 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/c6f7b413036791fab1bc70a20478e35308cb125e [PATCH] [ID 19991013.005] utime undef, undef, @files Date: Sat, 26 May 2001 20:05:23 -0400 Message-ID: <15120.17603.148648.12430@rls.cx> Subject: Re: [PATCH] [ID 19991013.005] utime undef, undef, @files From: rspier@pobox.com (Robert Spier) Date: Sun, 27 May 2001 00:23:12 -0400 Message-ID: <15120.33072.511966.767230@rls.cx> p4raw-id: //depot/perl@10232 --- diff --git a/doio.c b/doio.c index dd840f6..e86862f 100644 --- a/doio.c +++ b/doio.c @@ -1667,20 +1667,31 @@ nothing in the core. } utbuf; #endif + SV* accessed = *++mark; + SV* modified = *++mark; + void * utbufp = &utbuf; + + /* be like C, and if both times are undefined, let the C + library figure out what to do. This usually means + "current time" */ + + if ( accessed == &PL_sv_undef && modified == &PL_sv_undef ) + utbufp = NULL; + Zero(&utbuf, sizeof utbuf, char); #ifdef BIG_TIME - utbuf.actime = (Time_t)SvNVx(*++mark); /* time accessed */ - utbuf.modtime = (Time_t)SvNVx(*++mark); /* time modified */ + utbuf.actime = (Time_t)SvNVx(accessed); /* time accessed */ + utbuf.modtime = (Time_t)SvNVx(modified); /* time modified */ #else - utbuf.actime = (Time_t)SvIVx(*++mark); /* time accessed */ - utbuf.modtime = (Time_t)SvIVx(*++mark); /* time modified */ + utbuf.actime = (Time_t)SvIVx(accessed); /* time accessed */ + utbuf.modtime = (Time_t)SvIVx(modified); /* time modified */ #endif APPLY_TAINT_PROPER(); tot = sp - mark; while (++mark <= sp) { char *name = SvPVx(*mark, n_a); APPLY_TAINT_PROPER(); - if (PerlLIO_utime(name, &utbuf)) + if (PerlLIO_utime(name, utbufp)) tot--; } } diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 20714be..8912301 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -5622,6 +5622,13 @@ command if the files already exist: $now = time; utime $now, $now, @ARGV; +If the first two elements of the list are C, then the utime(2) +function in the C library will be called with a null second argument. +On most systems, this will set the file's access and modification +times to the current time. (i.e. equivalent to the example above.) + + utime undef, undef, @ARGV; + =item values HASH Returns a list consisting of all the values of the named hash. (In a