Skip Menu |

This queue is for tickets about the DateTime-Format-Natural CPAN distribution.

Report information
The Basics
Id: 29573
Status: resolved
Priority: 0/
Queue: DateTime-Format-Natural

People
Owner: Nobody in particular
Requestors: tj [...] solitudo.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.39
Fixed in: (no value)



Subject: Regression bug between 0.38 and 0.39
Hello, I noticed a script of mine is broken after upgrading to DateTime::Format:Natural 0.39. The script uses formats supplied by user so an instanace of DateTime::Format:Natural parser is used twice with same input, first for validation and then for computing actual DateTime objects. However, after upgrading to 0.39, this stopped working. The following oneliners show the issue first with 0.38 (works fine) and then with 0.39 (doesn't work): (16:19:56)(tj@shakti)(~)$ perl -I /home/staff/tj/.cpan/build/DateTime-Format-Natural-0.38-Xu8SzJ/lib -MDateTime::Format::Natural -e'$dt=DateTime::Format::Natural->new;$dt->parse_datetime("today");$dt->parse_datetime("5 minutes ago");$now=$dt->parse_datetime("today");$past=$dt->parse_datetime("5 minutes ago");printf "%s %s %s\n",$DateTime::Format::Natural::VERSION,$now,$past;die "regression bug" if $now eq $past' 0.38 2007-09-23T13:19:58 2007-09-23T13:14:58 (16:19:58)(tj@shakti)(~)$ perl -I /home/staff/tj/.cpan/build/DateTime-Format-Natural-0.39-ggdp0S/lib -MDateTime::Format::Natural -e'$dt=DateTime::Format::Natural->new;$dt->parse_datetime("today");$dt->parse_datetime("5 minutes ago");$now=$dt->parse_datetime("today");$past=$dt->parse_datetime("5 minutes ago");printf "%s %s %s\n",$DateTime::Format::Natural::VERSION,$now,$past;die "regression bug" if $now eq $past' 0.39 2007-09-23T13:20:01 2007-09-23T13:20:01 regression bug at -e line 1. (16:20:01)(tj@shakti)(~)$ So with 0.39, persing strings "today" and "5 minutes ago" results in the same DateTime object (the one that should be returned when parsing "today"). Version info: (16:25:41)(tj@shakti)(~)$ uname -a Linux shakti 2.6.20-16-server #2 SMP Fri Aug 31 01:01:45 UTC 2007 i686 GNU/Linux (16:25:43)(tj@shakti)(~)$ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.20-15-generic, archname=i686-linux-thread-multi uname='linux ganga 2.6.20-15-generic #2 smp sun apr 15 07:36:31 utc 2007 i686 gnulinux ' config_args='-ders -Dcc=gcc-4.1 -Dcpp=cpp-4.1 -Doptimize=-O3 -Accflags=-O3 -I/opt/local/include -Dprefix=/opt/local -Dusethreads -Duseithreads -Duseshrplib -Dlddlflags=-shared -Wl,-rpath -Wl,/opt/local/lib -L/opt/local/lib' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc-4.1', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -O3 -I/opt/local/include -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -O3 -I/opt/local/include -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include' ccversion='', gccversion='4.1.2 (Ubuntu 4.1.2-0ubuntu4)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc-4.1', ldflags =' -L/opt/local/lib' libpth=/opt/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/local/lib/perl5/5.8.8/i686-linux-thread-multi/CORE' cccdlflags='-fpic', lddlflags='-shared -Wl,-rpath -Wl,/opt/local/lib -L/opt/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Apr 28 2007 22:39:38 %ENV: PERL5_CPANPLUS_CONFIG="/home/staff/tj/.cpanplus/config" @INC: /opt/local/lib/perl5/5.8.8/i686-linux-thread-multi /opt/local/lib/perl5/5.8.8 /opt/local/lib/perl5/site_perl/5.8.8/i686-linux-thread-multi /opt/local/lib/perl5/site_perl/5.8.8 /opt/local/lib/perl5/site_perl . (16:25:46)(tj@shakti)(~)$
From: SCHUBIGER [...] cpan.org
On Sun Sep 23 09:26:36 2007, tj@solitudo.net wrote: Show quoted text
> I noticed a script of mine is broken after upgrading to > DateTime::Format:Natural 0.39. The script uses formats supplied by > user > so an instanace of DateTime::Format:Natural parser is used twice with > same input, first for validation and then for computing actual > DateTime > objects. However, after upgrading to 0.39, this stopped working. The > following oneliners show the issue first with 0.38 (works fine) and > then > with 0.39 (doesn't work):
Show quoted text
> So with 0.39, persing strings "today" and "5 minutes ago" results in > the > same DateTime object (the one that should be returned when parsing > "today").
Yes, this is a bug. With following change - Implemented mechanisms to mark tokens when processed and added an according getter method for multiple tokens. introduced, I forgot to empty the token buffer and thus some tokens have been skipped (as your report shows). By the way, using 'dateparse' or the methods success() & error() is recommended. 0.40 will be released soon.