mike            Wed Nov 15 17:14:50 2006 UTC

  Added files:                 
    /php-src/ext/gettext/tests  gettext_basic_de.phpt 
    /php-src/ext/gettext/tests/locale/de/LC_MESSAGES    messages.mo 
                                                        messages.po 

  Modified files:              
    /php-src/ext/gettext        gettext.c 
    /php-src/ext/gettext/tests  dcngettext.phpt gettext_basic.phpt 
  Log:
  - unicode upgrade
  # as setlocale() throws an E_STRICT deprecated warning, I guess we'll
    see ICU message catalogue support?
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/gettext.c?r1=1.50&r2=1.51&diff_format=u
Index: php-src/ext/gettext/gettext.c
diff -u php-src/ext/gettext/gettext.c:1.50 php-src/ext/gettext/gettext.c:1.51
--- php-src/ext/gettext/gettext.c:1.50  Tue Sep  5 10:35:53 2006
+++ php-src/ext/gettext/gettext.c       Wed Nov 15 17:14:50 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gettext.c,v 1.50 2006/09/05 10:35:53 tony2001 Exp $ */
+/* $Id: gettext.c,v 1.51 2006/11/15 17:14:50 mike Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -151,224 +151,175 @@
        php_info_print_table_end();
 }
 
-/* {{{ proto string textdomain(string domain)
+/* {{{ proto string textdomain(string domain) U
    Set the textdomain to "domain". Returns the current domain */
 PHP_NAMED_FUNCTION(zif_textdomain)
 {
-       zval **domain;
-       char *domain_name, *retval;
-       char *val;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &domain) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string_ex(domain);
-
-       val = Z_STRVAL_PP(domain);
-       if (strcmp(val, "") && strcmp(val, "0")) {
-               domain_name = val;
-       } else {
-               domain_name = NULL;
+       char *domain_str;
+       int domain_len;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", 
&domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)))) {
+               return;
        }
-
-       retval = textdomain(domain_name);
-
-       RETURN_STRING(retval, 1);
+       
+       if (!domain_len || (domain_len == 1 && *domain_str == '0')) {
+               domain_str = NULL;
+       }
+       RETURN_ASCII_STRING(textdomain(domain_str), 1);
 }
 /* }}} */
 
-/* {{{ proto string gettext(string msgid)
+/* {{{ proto binary gettext(string msgid) U
    Return the translation of msgid for the current domain, or msgid unaltered 
if a translation does not exist */
 PHP_NAMED_FUNCTION(zif_gettext)
 {
-       zval **msgid;
-       char *msgstr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &msgid) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *msgid_str;
+       int msgid_len;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", 
&msgid_str, &msgid_len, UG(ascii_conv))) {
+               return;
        }
-       convert_to_string_ex(msgid);
-
-       msgstr = gettext(Z_STRVAL_PP(msgid));
-
-       RETURN_STRING(msgstr, 1);
+       RETURN_STRING(gettext(msgid_str), 1);
 }
 /* }}} */
 
-/* {{{ proto string dgettext(string domain_name, string msgid)
+/* {{{ proto binary dgettext(string domain_name, string msgid) U
    Return the translation of msgid for domain_name, or msgid unaltered if a 
translation does not exist */
 PHP_NAMED_FUNCTION(zif_dgettext)
 {
-       zval **domain_name, **msgid;
-       char *msgstr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &domain_name, 
&msgid) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *domain_str, *msgid_str;
+       int domain_len, msgid_len;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", 
&domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), 
&msgid_str, &msgid_len, UG(ascii_conv))) {
+               return;
        }
-       convert_to_string_ex(domain_name);
-       convert_to_string_ex(msgid);
-
-       msgstr = dgettext(Z_STRVAL_PP(domain_name), Z_STRVAL_PP(msgid));
-
-       RETURN_STRING(msgstr, 1);
+       RETURN_STRING(dgettext(domain_str, msgid_str), 1);
 }
 /* }}} */
 
-/* {{{ proto string dcgettext(string domain_name, string msgid, long category)
+/* {{{ proto binary dcgettext(string domain_name, string msgid, int category) U
    Return the translation of msgid for domain_name and category, or msgid 
unaltered if a translation does not exist */
 PHP_NAMED_FUNCTION(zif_dcgettext)
 {
-       zval **domain_name, **msgid, **category;
-       char *msgstr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &domain_name, 
&msgid, &category) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *domain_str, *msgid_str;
+       int domain_len, msgid_len;
+       long category;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"s&s&l", &domain_str, &domain_len, 
ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str, &msgid_len, 
UG(ascii_conv), &category)) {
+               return;
        }
-       convert_to_string_ex(domain_name);
-       convert_to_string_ex(msgid);
-       convert_to_long_ex(category);
-
-       msgstr = dcgettext(Z_STRVAL_PP(domain_name), Z_STRVAL_PP(msgid), 
Z_LVAL_PP(category));
-
-       RETURN_STRING(msgstr, 1);
+       RETURN_STRING(dcgettext(domain_str, msgid_str, category), 1);
 }
 /* }}} */
 
-/* {{{ proto string bindtextdomain(string domain_name, string dir)
+/* {{{ proto string bindtextdomain(string domain_name, string dir) U
    Bind to the text domain domain_name, looking for translations in dir. 
Returns the current domain */
 PHP_NAMED_FUNCTION(zif_bindtextdomain)
 {
-       zval **domain_name, **dir;
-       char *retval, dir_name[MAXPATHLEN];
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &domain_name, 
&dir) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string_ex(domain_name);
-       convert_to_string_ex(dir);
-
-       if (Z_STRVAL_PP(domain_name)[0] == '\0') {
-               php_error(E_WARNING, "The first parameter of bindtextdomain 
must not be empty");
-               RETURN_FALSE;
+       char *domain_str, *dir_str, dir_tmp[MAXPATHLEN] = {0};
+       int domain_len, dir_len;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", 
&domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), 
&dir_str, &dir_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)))) {
+               return;
        }
        
-       if (Z_STRVAL_PP(dir)[0] != '\0' && strcmp(Z_STRVAL_PP(dir), "0")) {
-               VCWD_REALPATH(Z_STRVAL_PP(dir), dir_name);
+       if (!domain_len) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "the first 
parameter must not be empty");
+       }
+       if (!dir_len || (dir_len == 1 && *dir_str == '0')) {
+               VCWD_GETCWD(dir_tmp, sizeof(dir_tmp));
        } else {
-               VCWD_GETCWD(dir_name, MAXPATHLEN);
+               VCWD_REALPATH(dir_str, dir_tmp);
        }
-
-       retval = bindtextdomain(Z_STRVAL_PP(domain_name), dir_name);
-
-       RETURN_STRING(retval, 1);
+       RETURN_ASCII_STRING(bindtextdomain(domain_str, dir_tmp), 1);
 }
 /* }}} */
 
 #if HAVE_NGETTEXT
-/* {{{ proto string ngettext(string MSGID1, string MSGID2, int N)
+/* {{{ proto binary ngettext(string msgid1, string msgid2, int count) U
    Plural version of gettext() */
 PHP_NAMED_FUNCTION(zif_ngettext)
 {
-       zval **msgid1, **msgid2, **count;
-       char *msgstr;
-
-       RETVAL_FALSE;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &msgid1, &msgid2, 
&count) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *msgid_str1, *msgid_str2, *msgstr;
+       int msgid_len1, msgid_len2;
+       long count;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"s&s&l", &msgid_str1, &msgid_len1, UG(ascii_conv), &msgid_str2, &msgid_len2, 
UG(ascii_conv), &count)) {
+               RETURN_FALSE;
+       }
+       
+       if ((msgstr = ngettext(msgid_str1, msgid_str2, count))) {
+               RETURN_STRING(msgstr, 1);
        } else {
-               convert_to_string_ex(msgid1);
-               convert_to_string_ex(msgid2);
-               convert_to_long_ex(count);
-
-               msgstr = ngettext(Z_STRVAL_PP(msgid1), Z_STRVAL_PP(msgid2), 
Z_LVAL_PP(count));
-               if (msgstr) {
-                       RETVAL_STRING (msgstr, 1);
-               }
+               RETURN_FALSE;
        }
 }
 /* }}} */
 #endif
 
 #if HAVE_DNGETTEXT
-/* {{{ proto string dngettext (string domain, string msgid1, string msgid2, 
int count)
+/* {{{ proto binary dngettext (string domain, string msgid1, string msgid2, 
int count) U
    Plural version of dgettext() */
 PHP_NAMED_FUNCTION(zif_dngettext)
 {
-       zval **domain, **msgid1, **msgid2, **count;
-
-       RETVAL_FALSE;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &domain, &msgid1, 
&msgid2, &count) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *domain_str, *msgid_str1, *msgid_str2, *msgstr;
+       int domain_len, msgid_len1, msgid_len2;
+       long count;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"s&s&s&l", &domain_str, &domain_len, 
ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str1, &msgid_len1, 
UG(ascii_conv), &msgid_str2, &msgid_len2, UG(ascii_conv), &count)) {
+               RETURN_FALSE;
+       }
+       
+       if ((msgstr = dngettext(domain_str, msgid_str1, msgid_str2, count))) {
+               RETURN_STRING(msgstr, 1);
        } else {
-               char *msgstr;
-               
-               convert_to_string_ex(domain);
-               convert_to_string_ex(msgid1);
-               convert_to_string_ex(msgid2);
-               convert_to_long_ex(count);
-
-               msgstr = dngettext(Z_STRVAL_PP(domain), Z_STRVAL_PP(msgid1), 
Z_STRVAL_PP(msgid2), Z_LVAL_PP(count));
-               if (msgstr) {
-                       RETVAL_STRING(msgstr, 1);
-               }
+               RETURN_FALSE;
        }
 }
 /* }}} */
 #endif
 
 #if HAVE_DCNGETTEXT
-/* {{{ proto string dcngettext (string domain, string msgid1, string msgid2, 
int n, int category)
-   Plural version of dcgettext() */                                            
                
+/* {{{ proto binary dcngettext (string domain, string msgid1, string msgid2, 
int count, int category) U
+   Plural version of dcgettext() */
 PHP_NAMED_FUNCTION(zif_dcngettext)
 {
-       zval **domain, **msgid1, **msgid2, **count, **category;
-
-       RETVAL_FALSE;
-
-       if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &domain, &msgid1, 
&msgid2, &count, &category) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *domain_str, *msgid_str1, *msgid_str2, *msgstr;
+       int domain_len, msgid_len1, msgid_len2;
+       long count, category;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"s&s&s&ll", &domain_str, &domain_len, 
ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str1, &msgid_len1, 
UG(ascii_conv), &msgid_str2, &msgid_len2, UG(ascii_conv), &count, &category)) {
+               RETURN_FALSE;
+       }
+       
+       if ((msgstr = dcngettext(domain_str, msgid_str1, msgid_str2, count, 
category))) {
+               RETURN_STRING(msgstr, 1);
        } else {
-               char* msgstr = NULL;
-
-               convert_to_string_ex(domain);
-               convert_to_string_ex(msgid1);
-               convert_to_string_ex(msgid2);
-               convert_to_long_ex(count);
-               convert_to_long_ex(category);
-
-               msgstr = dcngettext(Z_STRVAL_PP(domain), Z_STRVAL_PP(msgid1), 
Z_STRVAL_PP(msgid2), Z_LVAL_PP(count), Z_LVAL_PP(category));
-
-               if (msgstr) {
-                       RETVAL_STRING(msgstr, 1);
-               }
+               RETURN_FALSE;
        }
 }
 /* }}} */
 #endif
 
 #if HAVE_BIND_TEXTDOMAIN_CODESET
-
-/* {{{ proto string bind_textdomain_codeset (string domain, string codeset)
+/* {{{ proto string bind_textdomain_codeset (string domain, string codeset) U
    Specify the character encoding in which the messages from the DOMAIN 
message catalog will be returned. */
 PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset)
 {
-       zval **domain, **codeset;
-       char *retval;
+       char *domain_str, *codeset_str, *codeset_ret;
+       int domain_len, codeset_len;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", 
&domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), 
&codeset_str, &codeset_len, UG(ascii_conv))) {
+               return;
+       }
        
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &domain, 
&codeset) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (!codeset_len) {
+               codeset_str = NULL;
+       }
+       if ((codeset_ret = bind_textdomain_codeset(domain_str, codeset_str))) {
+               RETURN_ASCII_STRING(codeset_ret, 1);
        } else {
-               convert_to_string_ex(domain);
-               convert_to_string_ex(codeset);
-               
-               retval = bind_textdomain_codeset(Z_STRVAL_PP(domain), 
Z_STRVAL_PP(codeset));
-
-               if (!retval) {
-                       RETURN_FALSE;
-               }
-               RETURN_STRING(retval, 1);
+               RETURN_FALSE;
        }
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/tests/dcngettext.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gettext/tests/dcngettext.phpt
diff -u php-src/ext/gettext/tests/dcngettext.phpt:1.1 
php-src/ext/gettext/tests/dcngettext.phpt:1.2
--- php-src/ext/gettext/tests/dcngettext.phpt:1.1       Tue Sep  5 10:35:53 2006
+++ php-src/ext/gettext/tests/dcngettext.phpt   Wed Nov 15 17:14:50 2006
@@ -19,7 +19,7 @@
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: Wrong parameter count for dcngettext() in %s on line %d
+Warning: dcngettext() expects exactly 5 parameters, 4 given in %s on line %d
 bool(false)
 string(1) "1"
 string(4) "test"
http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/tests/gettext_basic.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/gettext/tests/gettext_basic.phpt
diff -u php-src/ext/gettext/tests/gettext_basic.phpt:1.2 
php-src/ext/gettext/tests/gettext_basic.phpt:1.3
--- php-src/ext/gettext/tests/gettext_basic.phpt:1.2    Wed May 26 18:18:14 2004
+++ php-src/ext/gettext/tests/gettext_basic.phpt        Wed Nov 15 17:14:50 2006
@@ -1,7 +1,8 @@
 --TEST--
 Gettext basic test
 --SKIPIF--
-<?php 
+<?php
+       error_reporting(0);
        if (!extension_loaded("gettext")) {
                die("skip\n");
        }
@@ -10,9 +11,10 @@
        }
 ?>
 --FILE--
-<?php // $Id: gettext_basic.phpt,v 1.2 2004/05/26 18:18:14 iliaa Exp $
+<?php // $Id: gettext_basic.phpt,v 1.3 2006/11/15 17:14:50 mike Exp $
 
 chdir(dirname(__FILE__));
+putenv("LANGUAGE=fi");
 setlocale(LC_ALL, 'fi_FI');
 bindtextdomain ("messages", "./locale");
 textdomain ("messages");

http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/tests/gettext_basic_de.phpt?view=markup&rev=1.1
Index: php-src/ext/gettext/tests/gettext_basic_de.phpt
+++ php-src/ext/gettext/tests/gettext_basic_de.phpt
--TEST--
Gettext basic test
--SKIPIF--
<?php
        error_reporting(0);
        if (!extension_loaded("gettext")) {
                die("skip\n");
        }
        if (!setlocale(LC_ALL, 'de_DE')) {
                die("skip de_DE locale not supported.");
        }
?>
--FILE--
<?php
error_reporting(~E_STRICT);

chdir(dirname(__FILE__));
putenv("LANGUAGE=de");
setlocale(LC_ALL, 'de_DE');
bindtextdomain ("messages", "./locale");
textdomain ("messages");
var_dump(gettext("Basic test"));
var_dump(_("Basic test"));
var_dump(textdomain(0));
var_dump(textdomain(""));

?>
--EXPECT--
string(14) "Einfacher Test"
string(14) "Einfacher Test"
string(8) "messages"
string(8) "messages"
--UEXPECT--
string(14) "Einfacher Test"
string(14) "Einfacher Test"
unicode(8) "messages"
unicode(8) "messages"

http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.mo?view=markup&rev=1.1
Index: php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.mo
+++ php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.mo
Þ•

Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.po?view=markup&rev=1.1
Index: php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.po
+++ php-src/ext/gettext/tests/locale/de/LC_MESSAGES/messages.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <[EMAIL PROTECTED]>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"

#: gettext_basic.phpt:11
msgid "Basic test"
msgstr "Einfacher Test"

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

Reply via email to