logo       

cvs: ZendEngine2 / zend_operators.c: msg#00111

Subject: cvs: ZendEngine2 / zend_operators.c
andrei          Tue Aug 23 16:12:02 2005 EDT

  Modified files:              
    /ZendEngine2        zend_operators.c 
  Log:
  - Rewrite zend_u_binary_strncmp() to work on codepoint level. Calling
    u_strCompare() doesn't help because it assumes that the input lengths
    specify the number of UChar's.
  - Change zend_u_binary_strcmp() to use u_strCompare() (and it's fine to
    use it here, since we work with whole strings here).
  
  
http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.216&r2=1.217&ty=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.216 ZendEngine2/zend_operators.c:1.217
--- ZendEngine2/zend_operators.c:1.216  Tue Aug 23 12:37:24 2005
+++ ZendEngine2/zend_operators.c        Tue Aug 23 16:11:59 2005
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_operators.c,v 1.216 2005/08/23 16:37:24 andrei Exp $ */
+/* $Id: zend_operators.c,v 1.217 2005/08/23 20:11:59 andrei Exp $ */
 
 #include <ctype.h>
 
@@ -2199,22 +2199,15 @@
 
 ZEND_API int zend_u_binary_strcmp(UChar *s1, int32_t len1, UChar *s2, int32_t 
len2)
 {
-       int retval;
-       
-       retval = ZEND_NORMALIZE_BOOL(u_memcmpCodePointOrder(s1, s2, MIN(len1, 
len2)));
-       if (!retval) {
-               return (len1 - len2);
-       } else {
-               return retval;
-       }
+       return ZEND_NORMALIZE_BOOL(u_strCompare(s1, len1, s2, len2, 1));
 }
 
 
-ZEND_API int zend_u_binary_strncmp(UChar *s1, int32_t len1, UChar *s2, int32_t 
len2, uint length)
+ZEND_API int zend_binary_strncmp(char *s1, uint len1, char *s2, uint len2, 
uint length)
 {
        int retval;
        
-       retval = ZEND_NORMALIZE_BOOL(u_memcmpCodePointOrder(s1, s2, MIN(length, 
MIN(len1, len2))));
+       retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
        if (!retval) {
                return (MIN(length, len1) - MIN(length, len2));
        } else {
@@ -2223,16 +2216,23 @@
 }
 
 
-ZEND_API int zend_binary_strncmp(char *s1, uint len1, char *s2, uint len2, 
uint length)
+ZEND_API int zend_u_binary_strncmp(UChar *s1, int32_t len1, UChar *s2, int32_t 
len2, uint length)
 {
-       int retval;
-       
-       retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
-       if (!retval) {
-               return (MIN(length, len1) - MIN(length, len2));
-       } else {
-               return retval;
+       int32_t off1 = 0, off2 = 0;
+       UChar32 c1, c2;
+
+       for( ; length > 0; --length) {
+               if (off1 >= len1 || off2 >= len2) {
+                       return ZEND_NORMALIZE_BOOL(len1 - len2);
+               }
+               U16_NEXT(s1, off1, len1, c1);
+               U16_NEXT(s2, off2, len2, c2);
+               if (c1 != c2) {
+                       return ZEND_NORMALIZE_BOOL((int32_t)c1-(int32_t)c2);
+               }
        }
+
+       return 0;
 }
 
 

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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe