andrei          Wed Oct 25 17:28:21 2006 UTC

  Modified files:              
    /php-src/ext/standard       file.c 
  Log:
  Unicode support for fnmatch().
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.464&r2=1.465&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.464 php-src/ext/standard/file.c:1.465
--- php-src/ext/standard/file.c:1.464   Fri Oct 13 01:44:42 2006
+++ php-src/ext/standard/file.c Wed Oct 25 17:28:20 2006
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.464 2006/10/13 01:44:42 iliaa Exp $ */
+/* $Id: file.c,v 1.465 2006/10/25 17:28:20 andrei Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2562,22 +2562,36 @@
 /* }}} */
 
 #ifdef HAVE_FNMATCH
-/* {{{ proto bool fnmatch(string pattern, string filename [, int flags])
+/* {{{ proto bool fnmatch(string pattern, string filename [, int flags]) U
    Match filename against pattern */
 PHP_FUNCTION(fnmatch)
 {
-       char *pattern, *filename;
+       zstr pattern, filename;
        int pattern_len, filename_len;
+       char *pattern_utf8, *filename_utf8;
+       int pattern_utf8_len, filename_utf8_len;
+       zend_uchar type;
        long flags = 0;
+       UErrorCode status = U_ZERO_ERROR;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", 
-                                                         &pattern, 
&pattern_len, 
-                                                         &filename, 
&filename_len, 
-                                                         &flags) 
-               == FAILURE) 
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT|l", &pattern,
+                                                         &pattern_len, &type, 
&filename, &filename_len, &type, &flags) == FAILURE) {
                return;
+       }
+
+       if (type == IS_UNICODE) {
+               zend_unicode_to_string_ex(UG(utf8_conv), &pattern_utf8, 
&pattern_utf8_len, pattern.u, pattern_len, &status);
+               zend_unicode_to_string_ex(UG(utf8_conv), &filename_utf8, 
&filename_utf8_len, filename.u, filename_len, &status);
+               pattern.s = pattern_utf8;
+               filename.s = filename_utf8;
+       }
+
+       RETVAL_BOOL( ! fnmatch( pattern.s, filename.s, flags ));
        
-       RETURN_BOOL( ! fnmatch( pattern, filename, flags ));
+       if (type == IS_UNICODE) {
+               efree(pattern_utf8);
+               efree(filename_utf8);
+       }
 }
 /* }}} */
 #endif

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

Reply via email to