jay             Fri May 30 15:06:34 2003 EDT

  Modified files:              
    /php4/ext/standard  browscap.c 
  Log:
  Relying on longer matches seems to work better than
  matching the whole string with ^...$.
  
  
Index: php4/ext/standard/browscap.c
diff -u php4/ext/standard/browscap.c:1.75 php4/ext/standard/browscap.c:1.76
--- php4/ext/standard/browscap.c:1.75   Tue May 27 13:24:59 2003
+++ php4/ext/standard/browscap.c        Fri May 30 15:06:34 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: browscap.c,v 1.75 2003/05/27 17:24:59 sniper Exp $ */
+/* $Id: browscap.c,v 1.76 2003/05/30 19:06:34 jay Exp $ */
 
 #include "php.h"
 #include "php_regex.h"
@@ -47,10 +47,9 @@
        register int i, j;
        char *t;
 
-       t = (char *) malloc(Z_STRLEN_P(pattern)*2 + 3);
-       t[0] = '^';
+       t = (char *) malloc(Z_STRLEN_P(pattern)*2 + 1);
 
-       for (i=0, j=1; i<Z_STRLEN_P(pattern); i++, j++) {
+       for (i=0, j=0; i<Z_STRLEN_P(pattern); i++, j++) {
                switch (Z_STRVAL_P(pattern)[i]) {
                        case '?':
                                t[j] = '.';
@@ -73,7 +72,6 @@
                t[j++] = '*';
        }
 
-       t[j++]='$';
        t[j]=0;
        Z_STRVAL_P(pattern) = t;
        Z_STRLEN_P(pattern) = j;
@@ -196,14 +194,9 @@
        }
 
        if (*found_browser_entry) {
-               /* We've already found it, so don't compare to the default browser,
-                  because it will match anything. */
-               if (!strcmp(Z_STRVAL_PP(browser_name), "^.*$")) {
-                       return 0;
-               }
                /* If we've found a possible browser, check it's length. Longer user
                   agent strings are assumed to be more precise, so use them. */
-               else if (zend_hash_find(Z_ARRVAL_PP(found_browser_entry), 
"browser_name_regex", sizeof("browser_name_regex"), (void**) &current) == FAILURE) {
+               if (zend_hash_find(Z_ARRVAL_PP(found_browser_entry), 
"browser_name_regex", sizeof("browser_name_regex"), (void**) &current) == FAILURE) {
                        return 0;
                }
                else if (Z_STRLEN_PP(current) > Z_STRLEN_PP(browser_name)) {



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

Reply via email to