summaryrefslogtreecommitdiff
path: root/ext/gettext
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:36:21 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:36:21 -0400
commitd29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (patch)
treeb38e2e5c6974b9a15f103e5cf884cba9fff90ef4 /ext/gettext
parenta88a88d0986a4a32288c102cdbfebd78d7e91d99 (diff)
downloadphp-d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76.tar.gz
Imported Upstream version 5.2.0upstream/5.2.0
Diffstat (limited to 'ext/gettext')
-rw-r--r--ext/gettext/gettext.c93
-rw-r--r--ext/gettext/tests/dcngettext.phpt30
2 files changed, 111 insertions, 12 deletions
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 613b6c58b..60c6cb3b8 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gettext.c,v 1.46.2.2 2006/01/01 12:50:07 sniper Exp $ */
+/* $Id: gettext.c,v 1.46.2.2.2.2 2006/09/05 10:36:24 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -30,27 +30,96 @@
#include "ext/standard/info.h"
#include "php_gettext.h"
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO(arginfo_textdomain, 0)
+ ZEND_ARG_INFO(0, domain)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_gettext, 0)
+ ZEND_ARG_INFO(0, msgid)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dgettext, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, msgid)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dcgettext, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, msgid)
+ ZEND_ARG_INFO(0, category)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_bindtextdomain, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, dir)
+ZEND_END_ARG_INFO()
+
+#if HAVE_NGETTEXT
+static
+ZEND_BEGIN_ARG_INFO(arginfo_ngettext, 0)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_DNGETTEXT
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dngettext, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_DCNGETTEXT
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dcngettext, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ ZEND_ARG_INFO(0, category)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+static
+ZEND_BEGIN_ARG_INFO(arginfo_bind_textdomain_codeset, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, codeset)
+ZEND_END_ARG_INFO()
+#endif
+/* }}} */
+
/* {{{ php_gettext_functions[]
*/
zend_function_entry php_gettext_functions[] = {
- PHP_NAMED_FE(textdomain, zif_textdomain, NULL)
- PHP_NAMED_FE(gettext, zif_gettext, NULL)
+ PHP_NAMED_FE(textdomain, zif_textdomain, arginfo_textdomain)
+ PHP_NAMED_FE(gettext, zif_gettext, arginfo_gettext)
/* Alias for gettext() */
- PHP_NAMED_FE(_, zif_gettext, NULL)
- PHP_NAMED_FE(dgettext, zif_dgettext, NULL)
- PHP_NAMED_FE(dcgettext, zif_dcgettext, NULL)
- PHP_NAMED_FE(bindtextdomain, zif_bindtextdomain, NULL)
+ PHP_NAMED_FE(_, zif_gettext, arginfo_gettext)
+ PHP_NAMED_FE(dgettext, zif_dgettext, arginfo_dgettext)
+ PHP_NAMED_FE(dcgettext, zif_dcgettext, arginfo_dcgettext)
+ PHP_NAMED_FE(bindtextdomain, zif_bindtextdomain, arginfo_bindtextdomain)
#if HAVE_NGETTEXT
- PHP_NAMED_FE(ngettext, zif_ngettext, NULL)
+ PHP_NAMED_FE(ngettext, zif_ngettext, arginfo_ngettext)
#endif
#if HAVE_DNGETTEXT
- PHP_NAMED_FE(dngettext, zif_dngettext, NULL)
+ PHP_NAMED_FE(dngettext, zif_dngettext, arginfo_dngettext)
#endif
#if HAVE_DCNGETTEXT
- PHP_NAMED_FE(dcngettext, zif_dcngettext, NULL)
+ PHP_NAMED_FE(dcngettext, zif_dcngettext, arginfo_dcngettext)
#endif
#if HAVE_BIND_TEXTDOMAIN_CODESET
- PHP_NAMED_FE(bind_textdomain_codeset, zif_bind_textdomain_codeset, NULL)
+ PHP_NAMED_FE(bind_textdomain_codeset, zif_bind_textdomain_codeset, arginfo_bind_textdomain_codeset)
#endif
{NULL, NULL, NULL}
};
@@ -258,7 +327,7 @@ PHP_NAMED_FUNCTION(zif_dcngettext)
RETVAL_FALSE;
- if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(4, &domain, &msgid1, &msgid2, &count, &category) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &domain, &msgid1, &msgid2, &count, &category) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
char* msgstr = NULL;
diff --git a/ext/gettext/tests/dcngettext.phpt b/ext/gettext/tests/dcngettext.phpt
new file mode 100644
index 000000000..e5961eb1e
--- /dev/null
+++ b/ext/gettext/tests/dcngettext.phpt
@@ -0,0 +1,30 @@
+--TEST--
+dcngettext() tests
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) die("skip");
+if (!function_exists("dcngettext")) die("skip dcngettext() doesn't exist");
+?>
+--FILE--
+<?php
+
+var_dump(dcngettext(1,1,1,1));
+var_dump(dcngettext(1,1,1,1,1));
+var_dump(dcngettext("test","test","test",1,1));
+var_dump(dcngettext("test","test","test",0,0));
+var_dump(dcngettext("test","test","test",-1,-1));
+var_dump(dcngettext("","","",1,1));
+var_dump(dcngettext("","","",0,0));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: Wrong parameter count for dcngettext() in %s on line %d
+bool(false)
+string(1) "1"
+string(4) "test"
+string(4) "test"
+string(4) "test"
+string(0) ""
+string(0) ""
+Done