nlopess         Fri Nov 10 23:27:31 2006 UTC

  Modified files:              
    /php-src/ext/date/lib       parse_tz.c 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_tz.c?r1=1.31&r2=1.32&diff_format=u
Index: php-src/ext/date/lib/parse_tz.c
diff -u php-src/ext/date/lib/parse_tz.c:1.31 
php-src/ext/date/lib/parse_tz.c:1.32
--- php-src/ext/date/lib/parse_tz.c:1.31        Fri Nov 10 17:32:42 2006
+++ php-src/ext/date/lib/parse_tz.c     Fri Nov 10 23:27:31 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_tz.c,v 1.31 2006/11/10 17:32:42 nlopess Exp $ */
+/* $Id: parse_tz.c,v 1.32 2006/11/10 23:27:31 nlopess Exp $ */
 
 #include "timelib.h"
 
@@ -192,39 +192,26 @@
        }
 }
 
-static int tz_search(char *timezone, unsigned int left, unsigned int right, 
const timelib_tzdb *tzdb)
-{
-       int mid, cmp;
-
-       if (left > right) {
-               return -1; /* not found */
-       }
- 
-       mid = (left + right) / 2;
- 
-       cmp = strcasecmp(timezone, tzdb->index[mid].id);
-       if (cmp < 0) {
-               return tz_search(timezone, left, mid - 1, tzdb);
-       } else if (cmp > 0) {
-               return tz_search(timezone, mid + 1, right, tzdb);
-       } else { /* (cmp == 0) */
-               return tzdb->index[mid].pos;
-       }
-}
-
-
 static int seek_to_tz_position(const unsigned char **tzf, char *timezone, 
const timelib_tzdb *tzdb)
 {
-       int     pos;
-       
-       pos = tz_search(timezone, 0, tzdb->index_size - 1, tzdb);
+       int left = 0, right = tzdb->index_size - 1;
 
-       if (pos == -1) {
-               return 0;
-       }
+       do {
+               int mid = ((unsigned)left + right) >> 1;
+               int cmp = strcasecmp(timezone, tzdb->index[mid].id);
+
+               if (cmp < 0) {
+                       right = mid - 1;
+               } else if (cmp > 0) {
+                       left = mid + 1;
+               } else { /* (cmp == 0) */
+                       (*tzf) = &(tzdb->data[tzdb->index[mid].pos + 20]);
+                       return 1;
+               }
+
+       } while (left <= right);
 
-       (*tzf) = &(tzdb->data[pos + 20]);
-       return 1;
+       return 0;
 }
 
 const timelib_tzdb *timelib_builtin_db(void)

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

Reply via email to