]> granicus.if.org Git - php/commitdiff
Rebased to PHP-5.4
authorLonny Kapelushnik <lonnyk@gmail.com>
Mon, 14 Jan 2013 23:03:52 +0000 (23:03 +0000)
committerDerick Rethans <github@derickrethans.nl>
Sun, 31 Mar 2013 09:45:01 +0000 (10:45 +0100)
Implemented Dmitrys change from df97c3aa0d331be668bd5d8f27fff96d4e3ac1d7
Moved the timelib_parse_tz_cor function to ext/date/lib/timelib.c

ext/date/lib/parse_date.re
ext/date/lib/parse_iso_intervals.re
ext/date/lib/timelib.c
ext/date/lib/timelib.h
ext/date/php_date.c

index 06ab7e36bb9c27207eaffe979f2938445c285855..f3f5906b0a819dc3593cb29bbaa298f272020ba2 100644 (file)
@@ -168,8 +168,6 @@ typedef struct _timelib_relunit {
        int         multiplier;
 } timelib_relunit;
 
-#define HOUR(a) (int)(a * 60)
-
 /* The timezone table. */
 const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
 #include "timezonemap.h"
@@ -2238,39 +2236,6 @@ const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void)
        return timelib_timezone_lookup;
 }
 
-long timelib_parse_tz_cor(char **ptr)
-{
-       char *begin = *ptr, *end;
-       long  tmp;
-
-       while (isdigit(**ptr) || **ptr == ':') {
-               ++*ptr;
-       }
-       end = *ptr;
-       switch (end - begin) {
-               case 1:
-               case 2:
-                       return HOUR(strtol(begin, NULL, 10));
-                       break;
-               case 3:
-               case 4:
-                       if (begin[1] == ':') {
-                               tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
-                               return tmp;
-                       } else if (begin[2] == ':') {
-                               tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
-                               return tmp;
-                       } else {
-                               tmp = strtol(begin, NULL, 10);
-                               return HOUR(tmp / 100) + tmp % 100;
-                       }
-               case 5:
-                       tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
-                       return tmp;
-       }
-       return 0;
-}
-
 #ifdef DEBUG_PARSER_STUB
 int main(void)
 {
index 56aa34d8e005e7ec36ec4471c3d7308cf2308a04..e50ab37d3ba7f431cc61731368a97b9dec34edb0 100644 (file)
@@ -102,8 +102,6 @@ typedef struct Scanner {
        int have_end_date;
 } Scanner;
 
-#define HOUR(a) (int)(a * 60)
-
 static void add_warning(Scanner *s, char *error)
 {
        s->errors->warning_count++;
@@ -176,39 +174,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
        return dir * timelib_get_nr(ptr, max_length);
 }
 
-static long timelib_parse_tz_cor(char **ptr)
-{
-       char *begin = *ptr, *end;
-       long  tmp;
-
-       while (isdigit(**ptr) || **ptr == ':') {
-               ++*ptr;
-       }
-       end = *ptr;
-       switch (end - begin) {
-               case 1:
-               case 2:
-                       return HOUR(strtol(begin, NULL, 10));
-                       break;
-               case 3:
-               case 4:
-                       if (begin[1] == ':') {
-                               tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
-                               return tmp;
-                       } else if (begin[2] == ':') {
-                               tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
-                               return tmp;
-                       } else {
-                               tmp = strtol(begin, NULL, 10);
-                               return HOUR(tmp / 100) + tmp % 100;
-                       }
-               case 5:
-                       tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
-                       return tmp;
-       }
-       return 0;
-}
-
 static void timelib_eat_spaces(char **ptr)
 {
        while (**ptr == ' ' || **ptr == '\t') {
index 2f457a988244a3df1bb0a5ad6f6a4c73588b7588..84354e300f23122514c5cea9acddd8570451e838 100644 (file)
@@ -30,6 +30,8 @@
 
 #define TIMELIB_LLABS(y) (y < 0 ? (y * -1) : y)
 
+#define HOUR(a) (int)(a * 60)
+
 timelib_time* timelib_time_ctor(void)
 {
        timelib_time *t;
@@ -284,3 +286,35 @@ void timelib_dump_rel_time(timelib_rel_time *d)
        printf("\n");
 }
 
+long timelib_parse_tz_cor(char **ptr)
+{
+        char *begin = *ptr, *end;
+        long  tmp;
+
+        while (isdigit(**ptr) || **ptr == ':') {
+                ++*ptr;
+        }
+        end = *ptr;
+        switch (end - begin) {
+                case 1:
+                case 2:
+                        return HOUR(strtol(begin, NULL, 10));
+                        break;
+                case 3:
+                case 4:
+                        if (begin[1] == ':') {
+                                tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
+                                return tmp;
+                        } else if (begin[2] == ':') {
+                                tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+                                return tmp;
+                        } else {
+                                tmp = strtol(begin, NULL, 10);
+                                return HOUR(tmp / 100) + tmp % 100;
+                        }
+                case 5:
+                        tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+                        return tmp;
+        }
+        return 0;
+}
index d941cf6d0864ff2e957107f71aaf5467736c96ef..dfb7dc0300763619d7b3e590dcb3fb744ba9f060 100644 (file)
@@ -130,6 +130,7 @@ void timelib_dump_date(timelib_time *d, int options);
 void timelib_dump_rel_time(timelib_rel_time *d);
 
 void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec);
+long timelib_parse_tz_cor(char **ptr);
 
 /* from astro.c */
 double timelib_ts_to_juliandate(timelib_sll ts);
index eff82f68e627126c201e5228ca908df16da847da..0367726786d2d2165e54573f39cf7eeee5ba24d4 100644 (file)
@@ -633,6 +633,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
 static HashTable *date_object_get_gc_period(zval *object, zval ***table, int *n TSRMLS_DC);
 static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC);
 static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC);
+static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC);
 
 zval *date_interval_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC);
 void date_interval_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC);
@@ -2021,6 +2022,7 @@ static void date_register_classes(TSRMLS_D)
        memcpy(&date_object_handlers_timezone, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
        date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
        date_object_handlers_timezone.get_properties = date_object_get_properties_timezone;
+       date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
 
 #define REGISTER_TIMEZONE_CLASS_CONST_STRING(const_name, value) \
        zend_declare_class_constant_long(date_ce_timezone, const_name, sizeof(const_name)-1, value TSRMLS_CC);
@@ -2165,6 +2167,14 @@ static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_
        return zend_std_get_properties(object TSRMLS_CC);
 }
 
+static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC)
+{
+
+       *table = NULL;
+       *n = 0;
+       return zend_std_get_properties(object TSRMLS_CC);
+}
+
 static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
 {
        HashTable *props;
@@ -2284,7 +2294,7 @@ static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC)
 
        props = zend_std_get_properties(object TSRMLS_CC);
 
-       if (!tzobj->initialized || GC_G(gc_active)) {
+       if (!tzobj->initialized) {
                return props;
        }