Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH 5.5.650] fix 0 mday in POSIX::strftime #1183

Closed
p5pRT opened this issue Feb 15, 2000 · 1 comment
Closed

[PATCH 5.5.650] fix 0 mday in POSIX::strftime #1183

p5pRT opened this issue Feb 15, 2000 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Feb 15, 2000

Migrated from rt.perl.org#2153 (status was 'resolved')

Searchable as RT2153$

@p5pRT
Copy link
Author

p5pRT commented Feb 15, 2000

From jtobey@epsilondev.com

This is a bug report for perl from jtobey@​einstein.isay-secure.com,
generated with the help of perlbug 1.26 running under perl 5.00563.


POSIX​::strftime produces "0 Feb" for 31 Jan, "0 Apr" for 31 May, and
"0 Sep" for 31 Aug. This bug affects 5.5.650 as well as 5.00563. A
patch is included below.

  use POSIX 'strftime';
  for $m (0,2,4,6,7,9,11) {
  print strftime("%m %d\n",0,0,0,31,$m,100);
  }

=>
  02 00
  04 00
  05 31
  07 31
  09 00
  10 31
  12 31

Should be​:

  01 31
  03 31
  05 31
  07 31
  08 31
  10 31
  12 31

Inline Patch
--- perl5.5.650/ext/POSIX/POSIX.xs~	Sun Feb  6 14:25:22 2000
+++ perl5.5.650/ext/POSIX/POSIX.xs	Tue Feb 15 15:03:36 2000
@@ -510,8 +510,14 @@
 	}
     }
     ptm->tm_year = year - 1900;
-    ptm->tm_mon = month;
-    ptm->tm_mday = yearday;
+    if (yearday) {
+      ptm->tm_mday = yearday;
+      ptm->tm_mon = month;
+    }
+    else {
+      ptm->tm_mday = 31;
+      ptm->tm_mon = month - 1;
+    }
     /* re-build yearday based on Jan 1 to get tm_yday */
     year--;
     yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
--- perl5.5.650/t/lib/posix.t~	Tue Jan 18 15:34:59 2000
+++ perl5.5.650/t/lib/posix.t	Tue Feb 15 15:13:14 2000
@@ -14,7 +14,7 @@
 use strict subs;
 
 $| = 1;
-print "1..26\n";
+print "1..27\n";
 
 $Is_W32 = $^O eq 'MSWin32';
 
@@ -121,6 +121,7 @@
 try_strftime(24, "Mon Feb 28 00:00:00 2000 059", 0,0,0, 28,1,100);
 try_strftime(25, "Tue Feb 29 00:00:00 2000 060", 0,0,0, 0,2,100);
 try_strftime(26, "Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100);
+try_strftime(27, "Fri Mar 31 00:00:00 2000 091", 0,0,0, 31,2,100);
 &POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale};
 
 $| = 0;

-----------------------------------------------------------------

---
This perlbug was built using Perl 5.00503 - Wed May 26 09:55:29 EDT 1999 It is being executed now by Perl 5\.00563 \- Tue Feb 1 17​:54​:28 EST 2000\.

Site configuration information for perl 5.00563​:

Configured by jtobey at Tue Feb 1 17​:54​:28 EST 2000.

Summary of my perl5 (revision 5.0 version 5 subversion 63) configuration​:
  Platform​:
  osname=linux, osvers=2.0.36, archname=i686-linux
  uname='linux einstein 2.0.36 #2 sun feb 21 15​:55​:27 est 1999 i686 unknown '
  config_args='-Dprefix=/usr/local -Dcc=gcc -Doptimize=-g -O2 -ders'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  use64bits=undef usemultiplicity=undef
  Compiler​:
  cc='gcc', optimize='-g -O2', gccversion=2.7.2.3
  cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  stdchar='char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
  libc=/lib/libc-2.0.7.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl 5.00563​:
  /usr/local/lib/perl5/5.00563/i686-linux
  /usr/local/lib/perl5/5.00563
  /usr/local/lib/site_perl/5.00563/i686-linux
  /usr/local/lib/site_perl
  .


Environment for perl 5.00563​:
  HOME=/home/jtobey
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH=/home/oracle/product/8.0.5.0.0/lib
  LOGDIR (unset)
  PATH=/home/jtobey/bin​:/usr/local/bin​:/usr/local/sbin​:/usr/bin​:/usr/sbin​:/bin​:/sbin​:/usr/X11R6/bin​:/home/oracle/product/8.0.5.0.0/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant