[PHP-CVS] cvs: php-src /ext/date/lib dow.c parse_date.c parse_date.re timelib.h

2008-07-15 Thread Derick Rethans
derick  Tue Jul 15 17:37:33 2008 UTC

  Modified files:  
/php-src/ext/date/lib   dow.c parse_date.c parse_date.re timelib.h 
  Log:
  - Also add the warnings for times. This does not make sense for the english
text parser, as invalid times are never allowed in there.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/dow.c?r1=1.15&r2=1.16&diff_format=u
Index: php-src/ext/date/lib/dow.c
diff -u php-src/ext/date/lib/dow.c:1.15 php-src/ext/date/lib/dow.c:1.16
--- php-src/ext/date/lib/dow.c:1.15 Mon Jul 14 17:30:08 2008
+++ php-src/ext/date/lib/dow.c  Tue Jul 15 17:37:32 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: dow.c,v 1.15 2008/07/14 17:30:08 derick Exp $ */
+/* $Id: dow.c,v 1.16 2008/07/15 17:37:32 derick Exp $ */
 
 #include "timelib.h"
 
@@ -140,6 +140,14 @@
return day + ((w - 1) * 7) + d;
 }
 
+int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s)
+{
+   if (h < 0 || h > 23 || i < 0 || i > 59 || s < 0 || s > 59) {
+   return 0;
+   }
+   return 1;
+}
+
 int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d)
 {
if (m < 1 || m > 12 || d < 1 || d > timelib_days_in_month(y, m)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.93&r2=1.94&diff_format=u
Index: php-src/ext/date/lib/parse_date.c
diff -u php-src/ext/date/lib/parse_date.c:1.93 
php-src/ext/date/lib/parse_date.c:1.94
--- php-src/ext/date/lib/parse_date.c:1.93  Mon Jul 14 17:30:08 2008
+++ php-src/ext/date/lib/parse_date.c   Tue Jul 15 17:37:32 2008
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Jul 14 19:27:22 2008 */
+/* Generated by re2c 0.13.5 on Tue Jul 15 19:35:53 2008 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
+--+
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: parse_date.c,v 1.93 2008/07/14 17:30:08 derick Exp $ */
+/* $Id: parse_date.c,v 1.94 2008/07/15 17:37:32 derick Exp $ */
 
 #include "timelib.h"
 
@@ -23630,6 +23630,12 @@
}
}
 
+   /* do funky checking whether the parsed time was valid time */
+   if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
+   s->time->s != TIMELIB_UNSET && 
+   !timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
+   add_pbf_warning(s, "The parsed time was invalid", string, ptr);
+   }
/* do funky checking whether the parsed date was valid date */
if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
s->time->d != TIMELIB_UNSET && 
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.re?r1=1.84&r2=1.85&diff_format=u
Index: php-src/ext/date/lib/parse_date.re
diff -u php-src/ext/date/lib/parse_date.re:1.84 
php-src/ext/date/lib/parse_date.re:1.85
--- php-src/ext/date/lib/parse_date.re:1.84 Mon Jul 14 17:30:09 2008
+++ php-src/ext/date/lib/parse_date.re  Tue Jul 15 17:37:33 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: parse_date.re,v 1.84 2008/07/14 17:30:09 derick Exp $ */
+/* $Id: parse_date.re,v 1.85 2008/07/15 17:37:33 derick Exp $ */
 
 #include "timelib.h"
 
@@ -2040,6 +2040,12 @@
}
}
 
+   /* do funky checking whether the parsed time was valid time */
+   if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
+   s->time->s != TIMELIB_UNSET && 
+   !timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
+   add_pbf_warning(s, "The parsed time was invalid", string, ptr);
+   }
/* do funky checking whether the parsed date was valid date */
if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
s->time->d != TIMELIB_UNSET && 
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/timelib.h?r1=1.31&r2=1.32&diff_format=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.31 php-src/ext/date/lib/timelib.h:1.32
--- php-src/ext/date/lib/timelib.h:1.31 Mon Jul 14 17:30:09 2008
+++ php-src/ext/date/lib/timelib.h  Tue Jul 15 17:37:33 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: timelib.h,v 1.31 2008/07/14 17:30:09 derick Exp $ */
+/* $Id: timelib.h,v 1.32 2008/07/15 17:37:33 derick Exp $ */
 
 #ifndef __TIMELIB_H__
 #define __TIMELIB_H__
@@ -56,6 +56,7 @@
 timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, 
timelib_sll d);
 timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
 void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, 
timelib_sll *iw, timelib_sll *iy);
+int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s);
 int timelib_valid_date(timelib_sll y, timeli

[PHP-CVS] cvs: php-src /ext/date/lib dow.c

2008-02-22 Thread Derick Rethans
derick  Fri Feb 22 17:48:31 2008 UTC

  Modified files:  
/php-src/ext/date/lib   dow.c 
  Log:
  - Fixed bug #44216 (strftime segfaults on large negative value).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/dow.c?r1=1.13&r2=1.14&diff_format=u
Index: php-src/ext/date/lib/dow.c
diff -u php-src/ext/date/lib/dow.c:1.13 php-src/ext/date/lib/dow.c:1.14
--- php-src/ext/date/lib/dow.c:1.13 Mon Dec 31 07:12:08 2007
+++ php-src/ext/date/lib/dow.c  Fri Feb 22 17:48:31 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: dow.c,v 1.13 2007/12/31 07:12:08 sebastian Exp $ */
+/* $Id: dow.c,v 1.14 2008/02/22 17:48:31 derick Exp $ */
 
 #include "timelib.h"
 
@@ -35,10 +35,12 @@
 {
timelib_sll c1, y1, m1, dow;
 
-   /* Only valid for Gregorian calendar */
+   /* Only valid for Gregorian calendar, commented out as we don't handle
+* julian calendar. We just return the 'wrong' day of week to be
+* consistent.
if (y < 1753) {
return -1;
-   }
+   } */
c1 = century_value(y / 100);
y1 = (y % 100);
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php