iliaa           Wed Mar 17 20:35:51 2004 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src    NEWS 
    /php-src/ext/pgsql  pgsql.c 
  Log:
  MFH: Fixed bug #27300 (Improved regex for pg_convert()).
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.603&r2=1.1247.2.604&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.603 php-src/NEWS:1.1247.2.604
--- php-src/NEWS:1.1247.2.603   Wed Mar 17 12:26:13 2004
+++ php-src/NEWS        Wed Mar 17 20:35:49 2004
@@ -38,6 +38,8 @@
 - Fixed bug #27337 (missing sapi_shutdown() in sapi/isapi causes memory leak). 
   (Jani, msisolak at yahoo dot com)
 - Fixed bug #27328 (ftp extension relies on 32-bit longs). (Sara)
+- Fixed bug #27300 (Improved regex for pg_convert()).
+  (benjcarson at digitaljunkies dot ca, Ilia)
 - Fixed bug #27295 (memory leak inside sscanf()). (Ilia)
 - Fixed bug #27293 (two crashes inside image2wbmp()). (Ilia)
 - Fixed bug #27291 (get_browser matches browscap.ini patterns incorrectly).
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.244.2.33&r2=1.244.2.34&ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.244.2.33 php-src/ext/pgsql/pgsql.c:1.244.2.34
--- php-src/ext/pgsql/pgsql.c:1.244.2.33        Wed Jan 28 21:55:33 2004
+++ php-src/ext/pgsql/pgsql.c   Wed Mar 17 20:35:50 2004
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.244.2.33 2004/01/29 02:55:33 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.244.2.34 2004/03/18 01:35:50 iliaa Exp $ */
 
 #include <stdlib.h>
 
@@ -3853,16 +3853,63 @@
                                                        ZVAL_STRING(new_val, "NULL", 
1);
                                                }
                                                else {
-                                                       /* FIXME: better regex must be 
used */
-                                                       if 
(php_pgsql_convert_match(Z_STRVAL_PP(val), "^[+-]{0,1}[ 
\\t]+((second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[
 \\t]+)+([ \\t]+ago){0,1}$", 1 TSRMLS_CC) == FAILURE &&
-                                                               
php_pgsql_convert_match(Z_STRVAL_PP(val), "[EMAIL PROTECTED] \\t]+[+-]{0,1}[ 
\\t]+(second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[
 \\t]+)+([ \\t]+ago$", 1 TSRMLS_CC) == FAILURE) {
+
+                                                       /* From the Postgres docs:
+
+                                                          interval values can be 
written with the following syntax:
+                                                          [EMAIL PROTECTED] quantity 
unit [quantity unit...] [direction]
+                                                          
+                                                          Where: quantity is a number 
(possibly signed); unit is second, minute, hour,
+                                                          day, week, month, year, 
decade, century, millennium, or abbreviations or
+                                                          plurals of these units 
[note not *all* abbreviations] ; direction can be
+                                                          ago or empty. The at sign 
(@) is optional noise.
+                                                          
+                                                          ...
+                                                          
+                                                          Quantities of days, hours, 
minutes, and seconds can be specified without explicit
+                                                          unit markings. For example, 
'1 12:59:10' is read the same as '1 day 12 hours 59 min 10
+                                                          sec'.
+                                                       */                             
                           
+                                                       if 
(php_pgsql_convert_match(Z_STRVAL_PP(val),
+                                                                                      
                         "^(@?[ \\t]+)?("
+                                                                                      
                         
+                                                                                      
                         /* Textual time units and their abbreviations: */
+                                                                                      
                         "(([-+]?[ \\t]+)?"
+                                                                                      
                         "[0-9]+(\\.[0-9]*)?[ \\t]*"
+                                                                                      
                         "(millenniums|millennia|millennium|mil|mils|"
+                                                                                      
                         "centuries|century|cent|c|"
+                                                                                      
                         "decades|decade|dec|decs|"
+                                                                                      
                         "years|year|y|"
+                                                                                      
                         "months|month|mon|"
+                                                                                      
                         "weeks|week|w|" 
+                                                                                      
                         "days|day|d|"
+                                                                                      
                         "hours|hour|hr|hrs|h|"
+                                                                                      
                         "minutes|minute|mins|min|m|"
+                                                                                      
                         "seconds|second|secs|sec|s))+|"
+
+                                                                                      
                         /* Textual time units plus (dd)* hh[:mm[:ss]] */
+                                                                                      
                         "((([-+]?[ \\t]+)?"
+                                                                                      
                         "[0-9]+(\\.[0-9]*)?[ \\t]*"
+                                                                                      
                         "(millenniums|millennia|millennium|mil|mils|"
+                                                                                      
                         "centuries|century|cent|c|"
+                                                                                      
                         "decades|decade|dec|decs|"
+                                                                                      
                         "years|year|y|"
+                                                                                      
                         "months|month|mon|"
+                                                                                      
                         "weeks|week|w|"
+                                                                                      
                         "days|day|d))+" 
+                                                                                      
                         "([-+]?[ \\t]+"
+                                                                                      
                         "([0-9]+[ \\t]+)+"                               /* dd */
+                                                                                      
                         "(([0-9]{1,2}:){0,2}[0-9]{0,2})" /* hh:[mm:[ss]] */
+                                                                                      
                         ")?))"
+                                                                                      
                         "([ \\t]+ago)?$",
+                                                                                      
                         1 TSRMLS_CC) == FAILURE) {
                                                                err = 1;
                                                        }
                                                        else {
                                                                ZVAL_STRING(new_val, 
Z_STRVAL_PP(val), 1);
                                                                
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
                                                        }
-                                               }
+                                               }       
                                                break;
                                
                                        case IS_NULL:

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

Reply via email to