mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 02:15:42 +00:00
Compare commits
84
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c44e509e0 | ||
|
|
790d0057d7 | ||
|
|
8ae92cd4a5 | ||
|
|
b1c224914c | ||
|
|
eea75e7146 | ||
|
|
24b72e7a27 | ||
|
|
a186312832 | ||
|
|
56f9727305 | ||
|
|
ad1b9eef98 | ||
|
|
40a9316dff | ||
|
|
4268504084 | ||
|
|
95c57bb646 | ||
|
|
b80243aece | ||
|
|
5e66ce9293 | ||
|
|
b05c088a3a | ||
|
|
5558d0db9b | ||
|
|
636adf251c | ||
|
|
3a2660b302 | ||
|
|
8c88b6e81c | ||
|
|
442264ffd6 | ||
|
|
1010200da5 | ||
|
|
beda5093b4 | ||
|
|
f07e37c96d | ||
|
|
2f3056fecc | ||
|
|
1a4a9eede5 | ||
|
|
5a0da281e5 | ||
|
|
edd90e5ae3 | ||
|
|
1c3ed86211 | ||
|
|
9540ced221 | ||
|
|
2c8aeda6dc | ||
|
|
0ea731fc83 | ||
|
|
cc20351134 | ||
|
|
a0beddf5e9 | ||
|
|
7e5de3a1ce | ||
|
|
d08b4dbf23 | ||
|
|
7ab5c593f7 | ||
|
|
1ec83d44a1 | ||
|
|
91a9d24aa3 | ||
|
|
f244513fc0 | ||
|
|
fca1501ed6 | ||
|
|
3cb056f523 | ||
|
|
fca331cae9 | ||
|
|
2c204a55af | ||
|
|
1283722589 | ||
|
|
170cf3ec00 | ||
|
|
3616db6d38 | ||
|
|
4374a52e9d | ||
|
|
1df558c6a0 | ||
|
|
6612e1ba6a | ||
|
|
5efda763be | ||
|
|
17a57ad980 | ||
|
|
9b88bc494e | ||
|
|
b30304fb78 | ||
|
|
497b918e62 | ||
|
|
46566b78c9 | ||
|
|
87a87c6682 | ||
|
|
17f6391bf8 | ||
|
|
737c187013 | ||
|
|
ddd7ed9b24 | ||
|
|
1a624e27a6 | ||
|
|
4dc8610d34 | ||
|
|
8391277fb8 | ||
|
|
b9d494a33b | ||
|
|
28fa31d6e5 | ||
|
|
af41914e15 | ||
|
|
cedc718f73 | ||
|
|
e2fc6b52f0 | ||
|
|
721b9a7c8d | ||
|
|
e590aceb5a | ||
|
|
c2a9f73c99 | ||
|
|
a33759fd27 | ||
|
|
731013ee8e | ||
|
|
1533f98afd | ||
|
|
e73c05b75e | ||
|
|
362b70a32c | ||
|
|
eca13f7909 | ||
|
|
79b3c2a744 | ||
|
|
b1df743b7a | ||
|
|
c73b0543f1 | ||
|
|
33d372a45f | ||
|
|
816a5d2072 | ||
|
|
9137acc7ec | ||
|
|
9b54901ffb | ||
|
|
82a4f1a1a2 |
No files matched your search
@@ -1,8 +1,89 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2014, PHP 5.4.27
|
||||
01 May 2014, PHP 5.4.28
|
||||
|
||||
?? ??? 2014, PHP 5.4.26
|
||||
- Core:
|
||||
. Fixed bug #61019 (Out of memory on command stream_get_contents). (Mike)
|
||||
. Fixed bug #64330 (stream_socket_server() creates wrong Abstract Namespace
|
||||
UNIX sockets). (Mike)
|
||||
. Fixed bug #66171 (Symlinks and session handler allow open_basedir bypass).
|
||||
(Jann Horn, Stas)
|
||||
. Fixed bug #66182 (exit in stream filter produces segfault). (Mike)
|
||||
. Fixed bug #66736 (fpassthru broken). (Mike)
|
||||
. Fixed bug #67024 (getimagesize should recognize BMP files with negative
|
||||
height). (Gabor Buella)
|
||||
|
||||
- cURL:
|
||||
. Fixed bug #66562 (curl_exec returns differently than curl_multi_getcontent).
|
||||
(Freek Lijten)
|
||||
|
||||
- Date:
|
||||
. Fixed bug #66721 (__wakeup of DateTime segfaults when invalid object data is
|
||||
supplied). (Boro Sitnikovski)
|
||||
|
||||
- Embed:
|
||||
. Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol)
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #66987 (Memory corruption in fileinfo ext / bigendian).
|
||||
(Remi)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug #66482 (unknown entry 'priority' in php-fpm.conf).
|
||||
. Fixed bug #67060 (sapi/fpm: possible privilege escalation due to insecure
|
||||
default configuration) (CVE-2014-0185). (Stas)
|
||||
|
||||
- JSON:
|
||||
. Fixed bug #66021 (Blank line inside empty array/object when
|
||||
JSON_PRETTY_PRINT is set). (Kevin Israel)
|
||||
|
||||
- LDAP:
|
||||
. Fixed issue with null bytes in LDAP bindings. (Matthew Daley)
|
||||
|
||||
- OpenSSL:
|
||||
. Fix bug #66942 (memory leak in openssl_seal()). (Chuan Ma)
|
||||
. Fix bug #66952 (memory leak in openssl_open()). (Chuan Ma)
|
||||
|
||||
- SimpleXML:
|
||||
. Fixed bug #66084 (simplexml_load_string() mangles empty node name)
|
||||
(Anatol)
|
||||
|
||||
- XSL:
|
||||
. Fixed bug #53965 (<xsl:include> cannot find files with relative paths
|
||||
when loaded with "file://"). (Anatol)
|
||||
|
||||
- Apache2 Handler SAPI:
|
||||
. Fixed Apache log issue caused by APR's lack of support for %zu
|
||||
(APR issue https://issues.apache.org/bugzilla/show_bug.cgi?id=56120).
|
||||
(Jeff Trawick)
|
||||
|
||||
03 Apr 2014, PHP 5.4.27
|
||||
|
||||
- Core:
|
||||
. Fixed bug #60602 (proc_open() changes environment array) (Tjerk)
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #66946 (fileinfo: extensive backtracking in awk rule regular
|
||||
expression). (CVE-2013-7345) (Remi)
|
||||
|
||||
- FPM:
|
||||
. Added clear_env configuration directive to disable clearenv() call.
|
||||
(Github PR# 598, Paul Annesley)
|
||||
|
||||
- GMP
|
||||
. Fixed bug #66872 (invalid argument crashes gmp_testbit) (Pierre)
|
||||
|
||||
- Mail:
|
||||
. Fixed bug #66535 (Don't add newline after X-PHP-Originating-Script) (Tjerk)
|
||||
|
||||
- MySQLi:
|
||||
. Fixed bug #66762 (Segfault in mysqli_stmt::bind_result() when link closed)
|
||||
(Remi)
|
||||
|
||||
- Openssl:
|
||||
. Fixed bug #66833 (Default disgest algo is still MD5, switch to SHA1). (Remi)
|
||||
|
||||
06 Mar 2014, PHP 5.4.26
|
||||
|
||||
- JSON:
|
||||
. Fixed bug #65753 (JsonSerializeable couldn't implement on module extension)
|
||||
@@ -10,10 +91,7 @@ PHP NEWS
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #66731 (file: infinite recursion). (CVE-2014-1943) (Remi)
|
||||
|
||||
- FPM:
|
||||
. Added clear_env configuration directive to disable clearenv() call.
|
||||
(Github PR# 598, Paul Annesley)
|
||||
. Fixed bug #66820 (out-of-bounds memory access in fileinfo). (Remi)
|
||||
|
||||
- LDAP:
|
||||
. Implemented ldap_modify_batch (https://wiki.php.net/rfc/ldap_modify_batch).
|
||||
|
||||
+2
-2
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
|
||||
PHP_MAJOR_VERSION=5
|
||||
PHP_MINOR_VERSION=4
|
||||
PHP_RELEASE_VERSION=27
|
||||
PHP_EXTRA_VERSION="-dev"
|
||||
PHP_RELEASE_VERSION=28
|
||||
PHP_EXTRA_VERSION=""
|
||||
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
|
||||
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
|
||||
|
||||
|
||||
@@ -253,6 +253,8 @@ PHP_FUNCTION(curl_multi_getcontent)
|
||||
smart_str_0(&ch->handlers->write->buf);
|
||||
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1);
|
||||
}
|
||||
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
+467
-448
File diff suppressed because it is too large.
Load diff
+11
-12
@@ -28,7 +28,7 @@ static int month_tab[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 24
|
||||
static int days_in_month_leap[13] = { 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
static int days_in_month[13] = { 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
static int do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, timelib_sll *a, timelib_sll *b)
|
||||
static void do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, timelib_sll *a, timelib_sll *b)
|
||||
{
|
||||
if (*a < start) {
|
||||
*b -= (start - *a - 1) / adj + 1;
|
||||
@@ -38,7 +38,6 @@ static int do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, t
|
||||
*b += *a / adj;
|
||||
*a -= adj * (*a / adj);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void inc_month(timelib_sll *y, timelib_sll *m)
|
||||
@@ -170,24 +169,24 @@ static void do_adjust_for_weekday(timelib_time* time)
|
||||
|
||||
void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt)
|
||||
{
|
||||
do {} while (do_range_limit(0, 60, 60, &rt->s, &rt->i));
|
||||
do {} while (do_range_limit(0, 60, 60, &rt->i, &rt->h));
|
||||
do {} while (do_range_limit(0, 24, 24, &rt->h, &rt->d));
|
||||
do {} while (do_range_limit(0, 12, 12, &rt->m, &rt->y));
|
||||
do_range_limit(0, 60, 60, &rt->s, &rt->i);
|
||||
do_range_limit(0, 60, 60, &rt->i, &rt->h);
|
||||
do_range_limit(0, 24, 24, &rt->h, &rt->d);
|
||||
do_range_limit(0, 12, 12, &rt->m, &rt->y);
|
||||
|
||||
do_range_limit_days_relative(&base->y, &base->m, &rt->y, &rt->m, &rt->d, rt->invert);
|
||||
do {} while (do_range_limit(0, 12, 12, &rt->m, &rt->y));
|
||||
do_range_limit(0, 12, 12, &rt->m, &rt->y);
|
||||
}
|
||||
|
||||
void timelib_do_normalize(timelib_time* time)
|
||||
{
|
||||
if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->s, &time->i));
|
||||
if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->i, &time->h));
|
||||
if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 24, 24, &time->h, &time->d));
|
||||
do {} while (do_range_limit(1, 13, 12, &time->m, &time->y));
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->s, &time->i);
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 60, 60, &time->i, &time->h);
|
||||
if (time->s != TIMELIB_UNSET) do_range_limit(0, 24, 24, &time->h, &time->d);
|
||||
do_range_limit(1, 13, 12, &time->m, &time->y);
|
||||
|
||||
do {} while (do_range_limit_days(&time->y, &time->m, &time->d));
|
||||
do {} while (do_range_limit(1, 13, 12, &time->m, &time->y));
|
||||
do_range_limit(1, 13, 12, &time->m, &time->y);
|
||||
}
|
||||
|
||||
static void do_adjust_relative(timelib_time* time)
|
||||
|
||||
@@ -2587,6 +2587,10 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
|
||||
|
||||
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
|
||||
|
||||
if (tzi == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ALLOC_INIT_ZVAL(tmp_obj);
|
||||
tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC);
|
||||
tzobj->type = TIMELIB_ZONETYPE_ID;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Test for bug #66721: __wakeup of DateTime segfaults when invalid object data is supplied
|
||||
--CREDITS--
|
||||
Boro Sitnikovski <buritomath@yahoo.com>
|
||||
--FILE--
|
||||
<?php
|
||||
$y = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-02-15 02:00:51";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"1234567890";}';
|
||||
var_dump(unserialize($y));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Invalid serialization data for DateTime object in %s on line %d
|
||||
@@ -1509,6 +1509,12 @@ char *_dom_get_valid_file_path(char *source, char *resolved_path, int resolved_p
|
||||
|
||||
if (uri->scheme != NULL) {
|
||||
/* absolute file uris - libxml only supports localhost or empty host */
|
||||
#ifdef PHP_WIN32
|
||||
if (strncasecmp(source, "file://",7) == 0 && ':' == source[8]) {
|
||||
isFileUri = 1;
|
||||
source += 7;
|
||||
} else
|
||||
#endif
|
||||
if (strncasecmp(source, "file:///",8) == 0) {
|
||||
isFileUri = 1;
|
||||
#ifdef PHP_WIN32
|
||||
|
||||
+21281
-21281
File diff suppressed because it is too large.
Load diff
+154
-22
@@ -3000,7 +3000,7 @@ diff -u libmagic.orig/readelf.h libmagic/readelf.h
|
||||
typedef uint8_t Elf64_Char;
|
||||
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
--- libmagic.orig/softmagic.c Thu Mar 21 18:45:14 2013
|
||||
+++ libmagic/softmagic.c Thu Feb 20 18:57:46 2014
|
||||
+++ libmagic/softmagic.c Mon Mar 10 14:03:18 2014
|
||||
@@ -41,6 +41,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@@ -3013,7 +3013,16 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
|
||||
private int match(struct magic_set *, struct magic *, uint32_t,
|
||||
const unsigned char *, size_t, size_t, int, int, int, int, int *, int *,
|
||||
@@ -69,13 +74,13 @@
|
||||
@@ -62,6 +67,8 @@
|
||||
private void cvt_32(union VALUETYPE *, const struct magic *);
|
||||
private void cvt_64(union VALUETYPE *, const struct magic *);
|
||||
|
||||
+#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) > ((n) - (o)))
|
||||
+
|
||||
/*
|
||||
* softmagic - lookup one file in parsed, in-memory copy of database
|
||||
* Passed the name and FILE * of one file to be typed.
|
||||
@@ -69,13 +76,13 @@
|
||||
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
|
||||
protected int
|
||||
file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
|
||||
@@ -3029,7 +3038,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
NULL)) != 0)
|
||||
return rv;
|
||||
|
||||
@@ -132,7 +137,7 @@
|
||||
@@ -132,7 +139,7 @@
|
||||
struct magic *m = &magic[magindex];
|
||||
|
||||
if (m->type != FILE_NAME)
|
||||
@@ -3038,7 +3047,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
#define FLT (STRING_BINTEST | STRING_TEXTTEST)
|
||||
((text && (m->str_flags & FLT) == STRING_BINTEST) ||
|
||||
(!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
|
||||
@@ -209,8 +214,8 @@
|
||||
@@ -209,8 +216,8 @@
|
||||
if (file_check_mem(ms, ++cont_level) == -1)
|
||||
return -1;
|
||||
|
||||
@@ -3049,7 +3058,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
m = &magic[magindex];
|
||||
ms->line = m->lineno; /* for messages */
|
||||
|
||||
@@ -335,44 +340,22 @@
|
||||
@@ -335,44 +342,22 @@
|
||||
private int
|
||||
check_fmt(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
@@ -3104,7 +3113,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
private int32_t
|
||||
mprint(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
@@ -583,13 +566,13 @@
|
||||
@@ -583,13 +568,13 @@
|
||||
char *cp;
|
||||
int rval;
|
||||
|
||||
@@ -3120,7 +3129,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
|
||||
if (rval == -1)
|
||||
return -1;
|
||||
@@ -835,16 +818,16 @@
|
||||
@@ -835,16 +820,16 @@
|
||||
if (m->num_mask) \
|
||||
switch (m->mask_op & FILE_OPS_MASK) { \
|
||||
case FILE_OPADD: \
|
||||
@@ -3141,7 +3150,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
break; \
|
||||
} \
|
||||
|
||||
@@ -1145,9 +1128,6 @@
|
||||
@@ -1145,9 +1130,6 @@
|
||||
"nbytes=%zu, count=%u)\n", m->type, m->flag, offset, o,
|
||||
nbytes, count);
|
||||
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
|
||||
@@ -3151,7 +3160,79 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
}
|
||||
|
||||
if (m->flag & INDIR) {
|
||||
@@ -1644,16 +1624,13 @@
|
||||
@@ -1191,7 +1173,7 @@
|
||||
}
|
||||
switch (cvt_flip(m->in_type, flip)) {
|
||||
case FILE_BYTE:
|
||||
- if (nbytes < (offset + 1))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 1))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1226,7 +1208,7 @@
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_BESHORT:
|
||||
- if (nbytes < (offset + 2))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1278,7 +1260,7 @@
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_LESHORT:
|
||||
- if (nbytes < (offset + 2))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1330,7 +1312,7 @@
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_SHORT:
|
||||
- if (nbytes < (offset + 2))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1367,7 +1349,7 @@
|
||||
break;
|
||||
case FILE_BELONG:
|
||||
case FILE_BEID3:
|
||||
- if (nbytes < (offset + 4))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1438,7 +1420,7 @@
|
||||
break;
|
||||
case FILE_LELONG:
|
||||
case FILE_LEID3:
|
||||
- if (nbytes < (offset + 4))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1508,7 +1490,7 @@
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_MELONG:
|
||||
- if (nbytes < (offset + 4))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1578,7 +1560,7 @@
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_LONG:
|
||||
- if (nbytes < (offset + 4))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1644,23 +1626,20 @@
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0) {
|
||||
mdebug(offset, (char *)(void *)p,
|
||||
sizeof(union VALUETYPE));
|
||||
@@ -3165,20 +3246,57 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
switch (m->type) {
|
||||
case FILE_BYTE:
|
||||
- if (nbytes < (offset + 1)) /* should alway be true */
|
||||
+ if (nbytes < (offset + 1)) /* should always be true */
|
||||
+ if (OFFSET_OOB(nbytes, offset, 1))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
@@ -1703,6 +1680,8 @@
|
||||
case FILE_SHORT:
|
||||
case FILE_BESHORT:
|
||||
case FILE_LESHORT:
|
||||
- if (nbytes < (offset + 2))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
@@ -1679,38 +1658,40 @@
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
- if (nbytes < (offset + 4))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
- if (nbytes < (offset + 8))
|
||||
+ if (OFFSET_OOB(nbytes, offset, 8))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_STRING:
|
||||
case FILE_PSTRING:
|
||||
case FILE_SEARCH:
|
||||
- if (nbytes < (offset + m->vallen))
|
||||
+ if (OFFSET_OOB(nbytes, offset, m->vallen))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_REGEX:
|
||||
- if (nbytes < offset)
|
||||
+ if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_INDIRECT:
|
||||
- if (nbytes < offset)
|
||||
+ if (offset == 0)
|
||||
+ return 0;
|
||||
if (nbytes < offset)
|
||||
+ if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
sbuf = ms->o.buf;
|
||||
@@ -1710,19 +1689,21 @@
|
||||
soffset = ms->offset;
|
||||
ms->o.buf = NULL;
|
||||
ms->offset = 0;
|
||||
rv = file_softmagic(ms, s + offset, nbytes - offset,
|
||||
@@ -3187,24 +3305,38 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
|
||||
rbuf = ms->o.buf;
|
||||
ms->o.buf = sbuf;
|
||||
@@ -1718,16 +1699,26 @@
|
||||
ms->offset = soffset;
|
||||
if (rv == 1) {
|
||||
- if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
+ if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
file_printf(ms, m->desc, offset) == -1)
|
||||
- return -1;
|
||||
+ return -1;
|
||||
if (file_printf(ms, "%s", rbuf) == -1)
|
||||
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
- file_printf(ms, m->desc, offset) == -1)
|
||||
+ file_printf(ms, m->desc, offset) == -1) {
|
||||
+ if (rbuf) {
|
||||
+ efree(rbuf);
|
||||
+ }
|
||||
return -1;
|
||||
- if (file_printf(ms, "%s", rbuf) == -1)
|
||||
+ }
|
||||
+ if (file_printf(ms, "%s", rbuf) == -1) {
|
||||
+ if (rbuf) {
|
||||
+ efree(rbuf);
|
||||
+ }
|
||||
return -1;
|
||||
- free(rbuf);
|
||||
+ }
|
||||
+ }
|
||||
+ if (rbuf) {
|
||||
+ efree(rbuf);
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -1837,6 +1818,42 @@
|
||||
case FILE_USE:
|
||||
- if (nbytes < offset)
|
||||
+ if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
sbuf = m->value.s;
|
||||
if (*sbuf == '^') {
|
||||
@@ -1837,6 +1828,42 @@
|
||||
return file_strncmp(a, b, len, flags);
|
||||
}
|
||||
|
||||
@@ -3247,7 +3379,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
private int
|
||||
magiccheck(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
@@ -1996,69 +2013,157 @@
|
||||
@@ -1996,69 +2023,157 @@
|
||||
break;
|
||||
}
|
||||
case FILE_REGEX: {
|
||||
|
||||
@@ -493,12 +493,14 @@ apprentice_unmap(struct magic_map *map)
|
||||
if (map == NULL)
|
||||
return;
|
||||
if (map->p != php_magic_database) {
|
||||
int j;
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (map->magic[j])
|
||||
efree(map->magic[j]);
|
||||
}
|
||||
if (map->p != NULL) {
|
||||
if (map->p == NULL) {
|
||||
int j;
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (map->magic[j]) {
|
||||
efree(map->magic[j]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
efree(map->p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ private void cvt_16(union VALUETYPE *, const struct magic *);
|
||||
private void cvt_32(union VALUETYPE *, const struct magic *);
|
||||
private void cvt_64(union VALUETYPE *, const struct magic *);
|
||||
|
||||
#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) > ((n) - (o)))
|
||||
|
||||
/*
|
||||
* softmagic - lookup one file in parsed, in-memory copy of database
|
||||
* Passed the name and FILE * of one file to be typed.
|
||||
@@ -1171,7 +1173,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
}
|
||||
switch (cvt_flip(m->in_type, flip)) {
|
||||
case FILE_BYTE:
|
||||
if (nbytes < (offset + 1))
|
||||
if (OFFSET_OOB(nbytes, offset, 1))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1206,7 +1208,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_BESHORT:
|
||||
if (nbytes < (offset + 2))
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1258,7 +1260,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_LESHORT:
|
||||
if (nbytes < (offset + 2))
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1310,7 +1312,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_SHORT:
|
||||
if (nbytes < (offset + 2))
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1347,7 +1349,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
break;
|
||||
case FILE_BELONG:
|
||||
case FILE_BEID3:
|
||||
if (nbytes < (offset + 4))
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1418,7 +1420,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
break;
|
||||
case FILE_LELONG:
|
||||
case FILE_LEID3:
|
||||
if (nbytes < (offset + 4))
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1488,7 +1490,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_MELONG:
|
||||
if (nbytes < (offset + 4))
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1558,7 +1560,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
offset = ~offset;
|
||||
break;
|
||||
case FILE_LONG:
|
||||
if (nbytes < (offset + 4))
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
if (off) {
|
||||
switch (m->in_op & FILE_OPS_MASK) {
|
||||
@@ -1630,14 +1632,14 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
/* Verify we have enough data to match magic type */
|
||||
switch (m->type) {
|
||||
case FILE_BYTE:
|
||||
if (nbytes < (offset + 1)) /* should always be true */
|
||||
if (OFFSET_OOB(nbytes, offset, 1))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_SHORT:
|
||||
case FILE_BESHORT:
|
||||
case FILE_LESHORT:
|
||||
if (nbytes < (offset + 2))
|
||||
if (OFFSET_OOB(nbytes, offset, 2))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
@@ -1656,33 +1658,33 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
if (nbytes < (offset + 4))
|
||||
if (OFFSET_OOB(nbytes, offset, 4))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
if (nbytes < (offset + 8))
|
||||
if (OFFSET_OOB(nbytes, offset, 8))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_STRING:
|
||||
case FILE_PSTRING:
|
||||
case FILE_SEARCH:
|
||||
if (nbytes < (offset + m->vallen))
|
||||
if (OFFSET_OOB(nbytes, offset, m->vallen))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_REGEX:
|
||||
if (nbytes < offset)
|
||||
if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_INDIRECT:
|
||||
if (offset == 0)
|
||||
return 0;
|
||||
if (nbytes < offset)
|
||||
if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
sbuf = ms->o.buf;
|
||||
soffset = ms->offset;
|
||||
@@ -1696,11 +1698,19 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
ms->o.buf = sbuf;
|
||||
ms->offset = soffset;
|
||||
if (rv == 1) {
|
||||
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
file_printf(ms, m->desc, offset) == -1)
|
||||
return -1;
|
||||
if (file_printf(ms, "%s", rbuf) == -1)
|
||||
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
file_printf(ms, m->desc, offset) == -1) {
|
||||
if (rbuf) {
|
||||
efree(rbuf);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (file_printf(ms, "%s", rbuf) == -1) {
|
||||
if (rbuf) {
|
||||
efree(rbuf);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (rbuf) {
|
||||
efree(rbuf);
|
||||
@@ -1708,7 +1718,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
return rv;
|
||||
|
||||
case FILE_USE:
|
||||
if (nbytes < offset)
|
||||
if (OFFSET_OOB(nbytes, offset, 0))
|
||||
return 0;
|
||||
sbuf = m->value.s;
|
||||
if (*sbuf == '^') {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Patches applied to file sources tree before generating magic.mgc
|
||||
and before running create_data_file.php to create data_file.c.
|
||||
|
||||
|
||||
|
||||
From ef2329cf71acb59204dd981e2c6cce6c81fe467c Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Mon, 25 Mar 2013 14:06:55 +0000
|
||||
Subject: [PATCH] limit to 100 repetitions to avoid excessive backtracking
|
||||
Carsten Wolff
|
||||
|
||||
---
|
||||
magic/Magdir/commands | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/magic/Magdir/commands b/magic/Magdir/commands
|
||||
index 67c3eee..4a7d8dd 100644
|
||||
--- a/magic/Magdir/commands
|
||||
+++ b/magic/Magdir/commands
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
-# $File: commands,v 1.44 2013/02/05 15:20:47 christos Exp $
|
||||
+# $File: commands,v 1.45 2013/02/06 14:18:52 christos Exp $
|
||||
# commands: file(1) magic for various shells and interpreters
|
||||
#
|
||||
#0 string/w : shell archive or script for antique kernel text
|
||||
@@ -49,7 +49,7 @@
|
||||
!:mime text/x-awk
|
||||
0 string/wt #!\ /usr/bin/awk awk script text executable
|
||||
!:mime text/x-awk
|
||||
-0 regex =^\\s*BEGIN\\s*[{] awk script text
|
||||
+0 regex =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
|
||||
|
||||
# AT&T Bell Labs' Plan 9 shell
|
||||
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
|
||||
--
|
||||
1.8.5.5
|
||||
|
||||
@@ -1529,6 +1529,7 @@ ZEND_FUNCTION(gmp_testbit)
|
||||
if (mpz_tstbit(*gmpnum_a, index)) {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(interbase,for InterBase support,
|
||||
[ --with-interbase[=DIR] Include InterBase support. DIR is the InterBase base
|
||||
install directory [/usr/interbase]])
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("interbase", "InterBase support", "no");
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_IBASE_INCLUDES_H
|
||||
#define PHP_IBASE_INCLUDES_H
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/**
|
||||
* This UDF library adds the ability to call PHP functions from SQL
|
||||
* statements. Because of SQL's strong typing, you will have to declare
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_INTERBASE_H
|
||||
#define PHP_INTERBASE_H
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php /* $Id$ */
|
||||
<?php
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php /* $Id$ */
|
||||
<?php
|
||||
|
||||
if (!extension_loaded("interbase")) print "skip interbase extension not available";
|
||||
require("interbase.inc");
|
||||
|
||||
@@ -13,7 +13,10 @@ foreach($funcs as $func) {
|
||||
if($rfunc->getNumberOfRequiredParameters() == 0) {
|
||||
continue;
|
||||
}
|
||||
$res = $func($arg);
|
||||
|
||||
try {
|
||||
$res = $func($arg);
|
||||
} catch (Exception $e) { continue; }
|
||||
if($res != false) {
|
||||
echo "$func: ";
|
||||
var_dump($res);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
--TEST--
|
||||
Bug #50590 (IntlDateFormatter::parse result is limited to the integer range)
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
--TEST--
|
||||
Bug #62070: Collator::getSortKey() returns garbage
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip ICU >= 49 only');
|
||||
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '49') < 0) die('skip for ICU >= 49'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s1 = 'Hello';
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #62070: Collator::getSortKey() returns garbage
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s1 = 'Hello';
|
||||
|
||||
$coll = collator_create('en_US');
|
||||
$res = collator_get_sort_key($coll, $s1);
|
||||
|
||||
echo urlencode($res);
|
||||
--EXPECT--
|
||||
71%3F%3FE%01%09%01%DC%08
|
||||
@@ -2,6 +2,7 @@
|
||||
asort()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
--TEST--
|
||||
asort()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Sort associative arrays using various locales.
|
||||
*/
|
||||
|
||||
|
||||
$test_num = 1;
|
||||
|
||||
/*
|
||||
* Sort various arrays in specified locale.
|
||||
*/
|
||||
function sort_arrays( $locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach( $test_arrays as $test_array )
|
||||
{
|
||||
// Try to sort test data.
|
||||
$res_val = ut_coll_asort( $coll, $test_array, $sort_flag );
|
||||
|
||||
// Return output data.
|
||||
$res_dump = "\n" . dump( $test_array ) .
|
||||
"\n Result: " . dump( $res_val );
|
||||
|
||||
// Preppend test signature to output string
|
||||
$md5 = md5( $res_dump );
|
||||
|
||||
global $test_num;
|
||||
|
||||
$res_str .= "\n\n".
|
||||
"Test $test_num.$md5:" .
|
||||
$res_dump;
|
||||
++$test_num;
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test main function.
|
||||
*/
|
||||
function ut_main()
|
||||
{
|
||||
global $test_num;
|
||||
$test_num = 1;
|
||||
$res_str = '';
|
||||
|
||||
// Sort an array in SORT_REGULAR mode using en_US locale.
|
||||
$test_params = array(
|
||||
array( 'd' => 'y' ,
|
||||
'c' => 'i' ,
|
||||
'a' => 'k' ),
|
||||
|
||||
array( 'a' => 'a' ,
|
||||
'b' => 'aaa',
|
||||
'c' => 'aa' ),
|
||||
|
||||
array( 'a' => 'a' ,
|
||||
'aaa'=> 'a' ,
|
||||
'aa' => 'a' ),
|
||||
|
||||
array( '1' => 'abc',
|
||||
'5' => '!' ,
|
||||
'2' => null ,
|
||||
'7' => '' ),
|
||||
|
||||
array( '1' => '100',
|
||||
'2' => '25' ,
|
||||
'3' => '36' ),
|
||||
|
||||
array( '1' => 5 ,
|
||||
'2' => '30' ,
|
||||
'3' => 2 )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params );
|
||||
|
||||
// Sort an array in SORT_STRING mode using en_US locale.
|
||||
$test_params = array(
|
||||
array( '1' => '100',
|
||||
'2' => '25' ,
|
||||
'3' => '36' ),
|
||||
|
||||
array( '1' => 5 ,
|
||||
'2' => '30' ,
|
||||
'3' => 2 ),
|
||||
|
||||
array( '1' => 'd' ,
|
||||
'2' => '' ,
|
||||
'3' => ' a' ),
|
||||
|
||||
array( '1' => 'y' ,
|
||||
'2' => 'k' ,
|
||||
'3' => 'i' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
|
||||
|
||||
// Sort a non-ASCII array using ru_RU locale.
|
||||
$test_params = array(
|
||||
array( 'п' => 'у',
|
||||
'б' => 'в',
|
||||
'е' => 'а' ),
|
||||
|
||||
array( '1' => 'п',
|
||||
'4' => '',
|
||||
'7' => 'd',
|
||||
'2' => 'пп' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'ru_RU', $test_params );
|
||||
|
||||
|
||||
// Sort an array using Lithuanian locale.
|
||||
$test_params = array(
|
||||
array( 'd' => 'y',
|
||||
'c' => 'i',
|
||||
'a' => 'k' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str . "\n";
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
Test 1.162b81ac12878b817fc39063097e45b5:
|
||||
array (
|
||||
'c' => 'i',
|
||||
'a' => 'k',
|
||||
'd' => 'y',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 2.93d96e22f692d8a281b0a389f01f8d1e:
|
||||
array (
|
||||
'a' => 'a',
|
||||
'c' => 'aa',
|
||||
'b' => 'aaa',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 3.9f25de4482bc7b58de508e278113317c:
|
||||
array (
|
||||
'aa' => 'a',
|
||||
'aaa' => 'a',
|
||||
'a' => 'a',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 4.a85a41ea78e45b651080cfd98c0b431d:
|
||||
array (
|
||||
7 => '',
|
||||
2 => NULL,
|
||||
5 => '!',
|
||||
1 => 'abc',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 5.99dc71f405b286e03d489061b36e6900:
|
||||
array (
|
||||
2 => '25',
|
||||
3 => '36',
|
||||
1 => '100',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 6.bf5bba243307c9d12934e756ad4be190:
|
||||
array (
|
||||
3 => 2,
|
||||
1 => 5,
|
||||
2 => '30',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 7.e4ee7024c61476e9e7a6c28b5e47df6f:
|
||||
array (
|
||||
1 => '100',
|
||||
2 => '25',
|
||||
3 => '36',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 8.5fa7033dd43784be0db1474eb48b83c8:
|
||||
array (
|
||||
3 => 2,
|
||||
2 => '30',
|
||||
1 => 5,
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 9.588cdf4692bc09aa92ffe7e48f9e4579:
|
||||
array (
|
||||
2 => '',
|
||||
3 => ' a',
|
||||
1 => 'd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 10.be02641a47ebcccd23e4183ca3a415f7:
|
||||
array (
|
||||
3 => 'i',
|
||||
2 => 'k',
|
||||
1 => 'y',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 11.153d9b11d1e5936afc917a94a4e11f34:
|
||||
array (
|
||||
'е' => 'а',
|
||||
'б' => 'в',
|
||||
'п' => 'у',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 12.e1f5cb037b564dce39ffbd0a61562d59:
|
||||
array (
|
||||
4 => '',
|
||||
1 => 'п',
|
||||
2 => 'пп',
|
||||
7 => 'd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 13.8800d48abb960a59002eef77f1d73ae0:
|
||||
array (
|
||||
'c' => 'i',
|
||||
'd' => 'y',
|
||||
'a' => 'k',
|
||||
)
|
||||
Result: true
|
||||
@@ -2,6 +2,7 @@
|
||||
compare()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
--TEST--
|
||||
compare()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Compare various string pairs using various locales.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Converts comparison result to a character.
|
||||
*/
|
||||
function cmp_to_char( $comp_res )
|
||||
{
|
||||
switch( $comp_res )
|
||||
{
|
||||
case 0: // UCOL_EQUAL
|
||||
return '=';
|
||||
case 1: // UCOL_GREATER
|
||||
return '>';
|
||||
case -1: // UCOL_LESS
|
||||
return '<';
|
||||
default:
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare string pairs in the given array
|
||||
* using specified locale.
|
||||
*/
|
||||
function compare_pairs( $locale, $test_array )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach( $test_array as $test_strings )
|
||||
{
|
||||
list( $str1, $str2 ) = $test_strings;
|
||||
|
||||
// Compare strings.
|
||||
$res_val = cmp_to_char( ut_coll_compare( $coll, $str1, $str2 ) );
|
||||
|
||||
// Concatenate result strings.
|
||||
$res_str .= dump( $str1 ) .
|
||||
' ' . $res_val . ' ' .
|
||||
dump( $str2 ) . "\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
// Compare strings using en_US locale.
|
||||
$test_params = array(
|
||||
array( 'abc', 'abc' ),
|
||||
array( 'Abc', 'abc' ),
|
||||
array( 'a' , 'abc' ),
|
||||
array( 'a' , '' ),
|
||||
array( '' , '' ),
|
||||
array( 'a' , 'b' ),
|
||||
array( 'ab' , 'b' ),
|
||||
array( 'ab' , 'a' ),
|
||||
array( 123 , 'abc' ),
|
||||
array( 'ac' , null ),
|
||||
array( '.' , '.' ),
|
||||
// Try to compare long strings.
|
||||
array( 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde',
|
||||
'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'),
|
||||
array( null , null )
|
||||
);
|
||||
|
||||
$res_str .= compare_pairs( 'en_US', $test_params );
|
||||
|
||||
|
||||
// Compare strings using ru_RU locale.
|
||||
$test_params = array(
|
||||
array( 'а', 'б' ),
|
||||
array( 'а', 'аа' ),
|
||||
array( 'аб', 'ба' ),
|
||||
array( 'а', ',' ),
|
||||
array( 'а', 'b' ),
|
||||
array( 'а', 'bb' ),
|
||||
array( 'а', 'ab' ),
|
||||
array( 'а', null )
|
||||
);
|
||||
|
||||
$res_str .= compare_pairs( 'ru_RU', $test_params );
|
||||
|
||||
|
||||
// Compare strings using lt_LT locale.
|
||||
$test_params = array(
|
||||
array( 'y', 'k' )
|
||||
);
|
||||
|
||||
$res_str .= compare_pairs( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
'abc' = 'abc'
|
||||
'Abc' > 'abc'
|
||||
'a' < 'abc'
|
||||
'a' > ''
|
||||
'' = ''
|
||||
'a' < 'b'
|
||||
'ab' < 'b'
|
||||
'ab' > 'a'
|
||||
123 < 'abc'
|
||||
'ac' > NULL
|
||||
'.' = '.'
|
||||
'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde' < 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'
|
||||
NULL = NULL
|
||||
'а' < 'б'
|
||||
'а' < 'аа'
|
||||
'аб' < 'ба'
|
||||
'а' > ','
|
||||
'а' < 'b'
|
||||
'а' < 'bb'
|
||||
'а' < 'ab'
|
||||
'а' > NULL
|
||||
'y' < 'k'
|
||||
@@ -1,8 +1,9 @@
|
||||
--TEST--
|
||||
create() icu >= 4.8
|
||||
create() icu >= 4.8 && icu < 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip for ICU >= 4.8'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
--TEST--
|
||||
create() icu >= 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try creating collator with different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$locales = array(
|
||||
'EN-US-ODESSA',
|
||||
'UK_UA_ODESSA',
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
|
||||
);
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
// Create Collator with the current locale.
|
||||
$coll = ut_coll_create( $locale );
|
||||
if( !is_object($coll) )
|
||||
{
|
||||
$res_str .= "Error creating collator with '$locale' locale: " .
|
||||
intl_get_error_message() . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the requested, valid and actual locales.
|
||||
$vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
|
||||
$aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
|
||||
|
||||
// Show them.
|
||||
$res_str .= "Locale: '$locale'\n" .
|
||||
" ULOC_REQUESTED_LOCALE = '$locale'\n" .
|
||||
" ULOC_VALID_LOCALE = '$vloc'\n" .
|
||||
" ULOC_ACTUAL_LOCALE = '$aloc'\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Locale: 'EN-US-ODESSA'
|
||||
ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
|
||||
ULOC_VALID_LOCALE = 'en_US'
|
||||
ULOC_ACTUAL_LOCALE = 'root'
|
||||
Locale: 'UK_UA_ODESSA'
|
||||
ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
|
||||
ULOC_VALID_LOCALE = 'uk'
|
||||
ULOC_ACTUAL_LOCALE = 'uk'
|
||||
Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
ULOC_VALID_LOCALE = 'root'
|
||||
ULOC_ACTUAL_LOCALE = 'root'
|
||||
Locale: ''
|
||||
ULOC_REQUESTED_LOCALE = ''
|
||||
ULOC_VALID_LOCALE = '%s'
|
||||
ULOC_ACTUAL_LOCALE = '%s'
|
||||
Locale: 'root'
|
||||
ULOC_REQUESTED_LOCALE = 'root'
|
||||
ULOC_VALID_LOCALE = 'root'
|
||||
ULOC_ACTUAL_LOCALE = 'root'
|
||||
Locale: 'uk@currency=EURO'
|
||||
ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
|
||||
ULOC_VALID_LOCALE = 'uk'
|
||||
ULOC_ACTUAL_LOCALE = 'uk'
|
||||
Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR
|
||||
@@ -3,6 +3,8 @@ collator_get_sort_key()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?>
|
||||
<?php /* XXX Obviously it fails somewhere between >= 4.8 and < 51.2 */
|
||||
if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@@ -95,4 +97,4 @@ key: 5c0a161801070107
|
||||
source: жжж
|
||||
key: 5c3a3a3a01070107
|
||||
source: эюя
|
||||
key: 5d3b3f4501070107
|
||||
key: 5d3b3f4501070107
|
||||
@@ -0,0 +1,99 @@
|
||||
--TEST--
|
||||
collator_get_sort_key()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Get sort keys using various locales
|
||||
*/
|
||||
function sort_arrays( $locale, $data )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach($data as $value) {
|
||||
$res_val = ut_coll_get_sort_key( $coll, $value );
|
||||
$res_str .= "source: ".$value."\n".
|
||||
"key: ".bin2hex($res_val)."\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
// Regular strings keys
|
||||
$test_params = array(
|
||||
'abc', 'abd', 'aaa',
|
||||
'аа', 'а', 'z',
|
||||
'', null , '3',
|
||||
'y' , 'i' , 'k'
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params );
|
||||
|
||||
// Sort a non-ASCII array using ru_RU locale.
|
||||
$test_params = array(
|
||||
'абг', 'абв', 'жжж', 'эюя'
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'ru_RU', $test_params );
|
||||
|
||||
// Sort an array using Lithuanian locale.
|
||||
$res_str .= sort_arrays( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str . "\n";
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
source: abc
|
||||
key: 27292b01070107
|
||||
source: abd
|
||||
key: 27292d01070107
|
||||
source: aaa
|
||||
key: 27272701070107
|
||||
source: аа
|
||||
key: 5c0a0a01060106
|
||||
source: а
|
||||
key: 5c0a01050105
|
||||
source: z
|
||||
key: 5901050105
|
||||
source:
|
||||
key: 0101
|
||||
source:
|
||||
key: 0101
|
||||
source: 3
|
||||
key: 1801050105
|
||||
source: y
|
||||
key: 5701050105
|
||||
source: i
|
||||
key: 3701050105
|
||||
source: k
|
||||
key: 3b01050105
|
||||
source: абг
|
||||
key: 260a161a01070107
|
||||
source: абв
|
||||
key: 260a161801070107
|
||||
source: жжж
|
||||
key: 263a3a3a01070107
|
||||
source: эюя
|
||||
key: 273b3f4501070107
|
||||
source: абг
|
||||
key: 5c0a161a01070107
|
||||
source: абв
|
||||
key: 5c0a161801070107
|
||||
source: жжж
|
||||
key: 5c3a3a3a01070107
|
||||
source: эюя
|
||||
key: 5d3b3f4501070107
|
||||
@@ -0,0 +1,98 @@
|
||||
--TEST--
|
||||
collator_get_sort_key()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Get sort keys using various locales
|
||||
*/
|
||||
function sort_arrays( $locale, $data )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach($data as $value) {
|
||||
$res_val = ut_coll_get_sort_key( $coll, $value );
|
||||
$res_str .= "source: ".$value."\n".
|
||||
"key: ".bin2hex($res_val)."\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
// Regular strings keys
|
||||
$test_params = array(
|
||||
'abc', 'abd', 'aaa',
|
||||
'аа', 'а', 'z',
|
||||
'', null , '3',
|
||||
'y' , 'i' , 'k'
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params );
|
||||
|
||||
// Sort a non-ASCII array using ru_RU locale.
|
||||
$test_params = array(
|
||||
'абг', 'абв', 'жжж', 'эюя'
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'ru_RU', $test_params );
|
||||
|
||||
// Sort an array using Lithuanian locale.
|
||||
$res_str .= sort_arrays( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str . "\n";
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
source: abc
|
||||
key: 292b2d01070107
|
||||
source: abd
|
||||
key: 292b2f01070107
|
||||
source: aaa
|
||||
key: 29292901070107
|
||||
source: аа
|
||||
key: 5e090901060106
|
||||
source: а
|
||||
key: 5e0901050105
|
||||
source: z
|
||||
key: 5b01050105
|
||||
source:
|
||||
key: 0101
|
||||
source:
|
||||
key: 0101
|
||||
source: 3
|
||||
key: 1a01050105
|
||||
source: y
|
||||
key: 5901050105
|
||||
source: i
|
||||
key: 3901050105
|
||||
source: k
|
||||
key: 3d01050105
|
||||
source: абг
|
||||
key: 2809131701070107
|
||||
source: абв
|
||||
key: 2809131501070107
|
||||
source: жжж
|
||||
key: 2833333301070107
|
||||
source: эюя
|
||||
key: 28cdd1d501070107
|
||||
source: абг
|
||||
key: 5e09131701070107
|
||||
source: абв
|
||||
key: 5e09131501070107
|
||||
source: жжж
|
||||
key: 5e33333301070107
|
||||
source: эюя
|
||||
key: 5ecdd1d501070107
|
||||
@@ -2,6 +2,7 @@
|
||||
sort()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
--TEST--
|
||||
sort()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Sort arrays using various locales.
|
||||
*/
|
||||
|
||||
|
||||
$test_num = 1;
|
||||
|
||||
/*
|
||||
* Sort arrays in the given list using specified locale.
|
||||
*/
|
||||
function sort_arrays( $locale, $arrays, $sort_flag = Collator::SORT_REGULAR )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach( $arrays as $array )
|
||||
{
|
||||
// Sort array values
|
||||
$res_val = ut_coll_sort( $coll, $array, $sort_flag );
|
||||
|
||||
// Concatenate the sorted array and function result
|
||||
// with output string.
|
||||
$res_dump = "\n" . dump( $array ) .
|
||||
"\n Result: " . dump( $res_val );
|
||||
|
||||
// Preppend test signature to output string
|
||||
$md5 = md5( $res_dump );
|
||||
|
||||
global $test_num;
|
||||
|
||||
$res_str .= "\n\n".
|
||||
"Test $test_num.$md5:" .
|
||||
$res_dump;
|
||||
++$test_num;
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
global $test_num;
|
||||
$test_num = 1;
|
||||
$res_str = '';
|
||||
|
||||
// Sort an array in SORT_REGULAR mode using en_US locale.
|
||||
$test_params = array(
|
||||
array( 'abc', 'abd', 'aaa' ),
|
||||
array( 'm' , '1' , '_' ),
|
||||
array( 'a' , 'aaa', 'aa' ),
|
||||
array( 'ba' , 'b' , 'ab' ),
|
||||
array( 'e' , 'c' , 'a' ),
|
||||
array( '100', '25' , '36' ),
|
||||
array( 5 , '30' , 2 ),
|
||||
array( 'd' , '' , ' a' ),
|
||||
array( 'd ' , 'f ' , ' a' ),
|
||||
array( 'a' , null , '3' ),
|
||||
array( 'y' , 'k' , 'i' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params );
|
||||
|
||||
$test_params = array(
|
||||
array( '100', '25' , '36' ),
|
||||
array( 5 , '30' , 2 ),
|
||||
array( 'd' , '' , ' a' ),
|
||||
array( 'y' , 'k' , 'i' )
|
||||
);
|
||||
|
||||
// Sort in en_US locale with SORT_STRING flag
|
||||
$res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
|
||||
|
||||
|
||||
// Sort a non-ASCII array using ru_RU locale.
|
||||
$test_params = array(
|
||||
array( 'абг', 'абв', 'ааа', 'abc' ),
|
||||
array( 'аа', 'ааа' , 'а' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'ru_RU', $test_params );
|
||||
|
||||
// Sort an array using Lithuanian locale.
|
||||
$test_params = array(
|
||||
array( 'y' , 'k' , 'i' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
Test 1.e8f1cd28133d79ecd660002f1c660d0e:
|
||||
array (
|
||||
0 => 'aaa',
|
||||
1 => 'abc',
|
||||
2 => 'abd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 2.c2ded12173dd2996927378cae37eb275:
|
||||
array (
|
||||
0 => '_',
|
||||
1 => '1',
|
||||
2 => 'm',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 3.54071c968d71cb98c5d379145f8d7d38:
|
||||
array (
|
||||
0 => 'a',
|
||||
1 => 'aa',
|
||||
2 => 'aaa',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
|
||||
array (
|
||||
0 => 'ab',
|
||||
1 => 'b',
|
||||
2 => 'ba',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
|
||||
array (
|
||||
0 => 'a',
|
||||
1 => 'c',
|
||||
2 => 'e',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 6.ab530b060e5e54a65bfb8b9f8fc61870:
|
||||
array (
|
||||
0 => '25',
|
||||
1 => '36',
|
||||
2 => '100',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 7.0718dd838509017bded2ed307a6e785f:
|
||||
array (
|
||||
0 => 2,
|
||||
1 => 5,
|
||||
2 => '30',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 8.923d65739c5219c634616ffd100a50e4:
|
||||
array (
|
||||
0 => '',
|
||||
1 => ' a',
|
||||
2 => 'd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 9.289bc2f28e87d3201ec9d7e8477ae1b0:
|
||||
array (
|
||||
0 => ' a',
|
||||
1 => 'd ',
|
||||
2 => 'f ',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 10.de0fd958484f2377a645835d7fbcf124:
|
||||
array (
|
||||
0 => NULL,
|
||||
1 => '3',
|
||||
2 => 'a',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 11.dd2b8f0adb37c45d528cad1a0cc0f361:
|
||||
array (
|
||||
0 => 'i',
|
||||
1 => 'k',
|
||||
2 => 'y',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 12.1e6b4d6f7df9d4580317634ea46d8208:
|
||||
array (
|
||||
0 => '100',
|
||||
1 => '25',
|
||||
2 => '36',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 13.cec115dc9850b98dfbdf102efa09e61b:
|
||||
array (
|
||||
0 => 2,
|
||||
1 => '30',
|
||||
2 => 5,
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 14.923d65739c5219c634616ffd100a50e4:
|
||||
array (
|
||||
0 => '',
|
||||
1 => ' a',
|
||||
2 => 'd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 15.dd2b8f0adb37c45d528cad1a0cc0f361:
|
||||
array (
|
||||
0 => 'i',
|
||||
1 => 'k',
|
||||
2 => 'y',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 16.49056308afb2b800363c5baa735ed247:
|
||||
array (
|
||||
0 => 'ааа',
|
||||
1 => 'абв',
|
||||
2 => 'абг',
|
||||
3 => 'abc',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 17.91480b10473a0c96a4cd6d88c23c577a:
|
||||
array (
|
||||
0 => 'а',
|
||||
1 => 'аа',
|
||||
2 => 'ааа',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 18.fdd3fe3981476039164aa000bf9177f2:
|
||||
array (
|
||||
0 => 'i',
|
||||
1 => 'y',
|
||||
2 => 'k',
|
||||
)
|
||||
Result: true
|
||||
@@ -2,6 +2,7 @@
|
||||
sort_with_sort_keys()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
--TEST--
|
||||
sort_with_sort_keys()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Sort arrays using various locales.
|
||||
*/
|
||||
|
||||
|
||||
$test_num = 1;
|
||||
|
||||
/*
|
||||
* Sort arrays in the given list using specified locale.
|
||||
*/
|
||||
function sort_arrays( $locale, $arrays )
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$coll = ut_coll_create( $locale );
|
||||
|
||||
foreach( $arrays as $array )
|
||||
{
|
||||
// Sort array values
|
||||
$res_val = ut_coll_sort_with_sort_keys( $coll, $array );
|
||||
|
||||
// Concatenate the sorted array and function result
|
||||
// with output string.
|
||||
$res_dump = "\n" . dump( $array ) .
|
||||
"\n Result: " . dump( $res_val );
|
||||
|
||||
|
||||
// Preppend test signature to output string
|
||||
$md5 = md5( $res_dump );
|
||||
|
||||
global $test_num;
|
||||
|
||||
$res_str .= "\n\n".
|
||||
"Test $test_num.$md5:" .
|
||||
$res_dump;
|
||||
++$test_num;
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
global $test_num;
|
||||
$test_num = 1;
|
||||
$res_str = '';
|
||||
|
||||
// Sort an array in SORT_REGULAR mode using en_US locale.
|
||||
$test_params = array(
|
||||
array( 'abc', 'abd', 'aaa' ),
|
||||
array( 'm' , '1' , '_' ),
|
||||
array( 'a' , 'aaa', 'aa' ),
|
||||
array( 'ba' , 'b' , 'ab' ),
|
||||
array( 'e' , 'c' , 'a' ),
|
||||
array( 'd' , '' , ' a' ),
|
||||
array( 'd ' , 'f ' , ' a' ),
|
||||
array( 'a' , null , '3' ),
|
||||
array( 'y' , 'i' , 'k' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'en_US', $test_params );
|
||||
|
||||
// Sort a non-ASCII array using ru_RU locale.
|
||||
$test_params = array(
|
||||
array( 'абг', 'абв', 'ааа', 'abc' ),
|
||||
array( 'аа', 'ааа', 'а' )
|
||||
);
|
||||
|
||||
$res_str .= sort_arrays( 'ru_RU', $test_params );
|
||||
|
||||
// Array with data for sorting.
|
||||
$test_params = array(
|
||||
array( 'y' , 'i' , 'k' )
|
||||
);
|
||||
|
||||
// Sort an array using Lithuanian locale.
|
||||
$res_str .= sort_arrays( 'lt_LT', $test_params );
|
||||
|
||||
return $res_str . "\n";
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
Test 1.e8f1cd28133d79ecd660002f1c660d0e:
|
||||
array (
|
||||
0 => 'aaa',
|
||||
1 => 'abc',
|
||||
2 => 'abd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 2.c2ded12173dd2996927378cae37eb275:
|
||||
array (
|
||||
0 => '_',
|
||||
1 => '1',
|
||||
2 => 'm',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 3.54071c968d71cb98c5d379145f8d7d38:
|
||||
array (
|
||||
0 => 'a',
|
||||
1 => 'aa',
|
||||
2 => 'aaa',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
|
||||
array (
|
||||
0 => 'ab',
|
||||
1 => 'b',
|
||||
2 => 'ba',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
|
||||
array (
|
||||
0 => 'a',
|
||||
1 => 'c',
|
||||
2 => 'e',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 6.923d65739c5219c634616ffd100a50e4:
|
||||
array (
|
||||
0 => '',
|
||||
1 => ' a',
|
||||
2 => 'd',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 7.289bc2f28e87d3201ec9d7e8477ae1b0:
|
||||
array (
|
||||
0 => ' a',
|
||||
1 => 'd ',
|
||||
2 => 'f ',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 8.de0fd958484f2377a645835d7fbcf124:
|
||||
array (
|
||||
0 => NULL,
|
||||
1 => '3',
|
||||
2 => 'a',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 9.dd2b8f0adb37c45d528cad1a0cc0f361:
|
||||
array (
|
||||
0 => 'i',
|
||||
1 => 'k',
|
||||
2 => 'y',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 10.49056308afb2b800363c5baa735ed247:
|
||||
array (
|
||||
0 => 'ааа',
|
||||
1 => 'абв',
|
||||
2 => 'абг',
|
||||
3 => 'abc',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 11.91480b10473a0c96a4cd6d88c23c577a:
|
||||
array (
|
||||
0 => 'а',
|
||||
1 => 'аа',
|
||||
2 => 'ааа',
|
||||
)
|
||||
Result: true
|
||||
|
||||
Test 12.fdd3fe3981476039164aa000bf9177f2:
|
||||
array (
|
||||
0 => 'i',
|
||||
1 => 'y',
|
||||
2 => 'k',
|
||||
)
|
||||
Result: true
|
||||
@@ -0,0 +1,45 @@
|
||||
--TEST--
|
||||
IntlDateFormatter, calendars and time zone
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$fmt1 = new IntlDateFormatter('en_US',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::FULL,
|
||||
'GMT+05:12',
|
||||
IntlDateFormatter::TRADITIONAL);
|
||||
$fmt2 = new IntlDateFormatter('en_US',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::FULL,
|
||||
'GMT+05:12',
|
||||
IntlDateFormatter::GREGORIAN);
|
||||
$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::FULL,
|
||||
'GMT+05:12',
|
||||
IntlDateFormatter::TRADITIONAL);
|
||||
var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
|
||||
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
|
||||
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
|
||||
|
||||
new IntlDateFormatter('en_US@calendar=hebrew',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::FULL,
|
||||
'GMT+05:12',
|
||||
-1);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
|
||||
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
|
||||
string(48) "Sunday, Tevet 6, 5772 AM at 5:12:00 AM GMT+05:12"
|
||||
|
||||
Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant2.php on line %d
|
||||
==DONE==
|
||||
@@ -0,0 +1,85 @@
|
||||
--TEST--
|
||||
datefmt_set_timezone_id_code() icu >= 4.8
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("error_reporting", ~E_DEPRECATED);
|
||||
|
||||
/*
|
||||
* Test for the datefmt_set_timezone_id function
|
||||
*/
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$timezone_id_arr = array (
|
||||
'America/New_York',
|
||||
'America/Los_Angeles',
|
||||
'America/Chicago',
|
||||
'CN'
|
||||
);
|
||||
$timestamp_entry = 0;
|
||||
|
||||
$res_str = '';
|
||||
|
||||
$fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN );
|
||||
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
|
||||
$res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";
|
||||
|
||||
foreach( $timezone_id_arr as $timezone_id_entry )
|
||||
{
|
||||
|
||||
$res_str .= "-----------";
|
||||
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
|
||||
ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
|
||||
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
|
||||
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
|
||||
$formatted = ut_datefmt_format( $fmt, 0);
|
||||
$res_str .= "\nFormatting timestamp=0 resulted in $formatted";
|
||||
$formatted = ut_datefmt_format( $fmt, 3600);
|
||||
$res_str .= "\nFormatting timestamp=3600 resulted in $formatted";
|
||||
$res_str .= "\n";
|
||||
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlDateFormatter::setTimeZoneId(): datefmt_set_timezone: no such time zone: 'CN' in %sut_common.inc on line %d
|
||||
|
||||
Warning: datefmt_set_timezone_id(): datefmt_set_timezone: no such time zone: 'CN' in %sut_common.inc on line %d
|
||||
|
||||
After creation of the dateformatter : timezone_id= US/Pacific
|
||||
-----------
|
||||
Trying to set timezone_id= America/New_York
|
||||
After call to set_timezone_id : timezone_id= America/New_York
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Eastern Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 8:00:00 PM Eastern Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= America/Los_Angeles
|
||||
After call to set_timezone_id : timezone_id= America/Los_Angeles
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 4:00:00 PM Pacific Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 5:00:00 PM Pacific Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= America/Chicago
|
||||
After call to set_timezone_id : timezone_id= America/Chicago
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= CN
|
||||
After call to set_timezone_id : timezone_id= America/Chicago
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time
|
||||
@@ -2,7 +2,7 @@
|
||||
numfmt_format() icu >= 4.8
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
--TEST--
|
||||
numfmt_format() icu >= 52.1 && icu < 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '52.1') < 0) print 'skip for ICU >= 52.1'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Format a number using misc locales/patterns.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
|
||||
* currency and percent formatting.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$styles = array(
|
||||
NumberFormatter::PATTERN_DECIMAL => '##.#####################',
|
||||
NumberFormatter::DECIMAL => '',
|
||||
NumberFormatter::CURRENCY => '',
|
||||
NumberFormatter::PERCENT => '',
|
||||
NumberFormatter::SCIENTIFIC => '',
|
||||
NumberFormatter::SPELLOUT => '@@@@@@@',
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
NumberFormatter::PATTERN_RULEBASED => '#####.###',
|
||||
1234999, // bad one
|
||||
);
|
||||
|
||||
$integer = array(
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
);
|
||||
$locales = array(
|
||||
'en_US',
|
||||
'ru_UA',
|
||||
'de',
|
||||
'fr',
|
||||
'en_UK'
|
||||
);
|
||||
|
||||
$str_res = '';
|
||||
$number = 1234567.891234567890000;
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$str_res .= "\nLocale is: $locale\n";
|
||||
foreach( $styles as $style => $pattern )
|
||||
{
|
||||
$fmt = ut_nfmt_create( $locale, $style, $pattern );
|
||||
|
||||
if(!$fmt) {
|
||||
$str_res .= "Bad formatter!\n";
|
||||
continue;
|
||||
}
|
||||
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
|
||||
}
|
||||
}
|
||||
return $str_res;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
Locale is: en_US
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'\$1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: ru_UA
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ?(грн\.|₴)'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь'
|
||||
'1 234 567.?'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: de
|
||||
'1234567,89123457'
|
||||
'1.234.567,891'
|
||||
'(¤ )?1.234.567,89( ¤)?'
|
||||
'123\.456\.789 %'
|
||||
'1,23456789123457E6'
|
||||
'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig Komma acht neun eins zwei drei vier fünf sieben'
|
||||
'1.234.567.?'
|
||||
'1.234.567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: fr
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ¤'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept'
|
||||
'1 234 567e'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
|
||||
Locale is: en_UK
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'¤1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
Bad formatter!
|
||||
@@ -0,0 +1,130 @@
|
||||
--TEST--
|
||||
numfmt_format() icu >= 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Format a number using misc locales/patterns.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
|
||||
* currency and percent formatting.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$styles = array(
|
||||
NumberFormatter::PATTERN_DECIMAL => '##.#####################',
|
||||
NumberFormatter::DECIMAL => '',
|
||||
NumberFormatter::CURRENCY => '',
|
||||
NumberFormatter::PERCENT => '',
|
||||
NumberFormatter::SCIENTIFIC => '',
|
||||
NumberFormatter::SPELLOUT => '@@@@@@@',
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
NumberFormatter::PATTERN_RULEBASED => '#####.###',
|
||||
1234999, // bad one
|
||||
);
|
||||
|
||||
$integer = array(
|
||||
NumberFormatter::ORDINAL => '',
|
||||
NumberFormatter::DURATION => '',
|
||||
);
|
||||
$locales = array(
|
||||
'en_US',
|
||||
'ru_UA',
|
||||
'de',
|
||||
'fr',
|
||||
'en_UK'
|
||||
);
|
||||
|
||||
$str_res = '';
|
||||
$number = 1234567.891234567890000;
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$str_res .= "\nLocale is: $locale\n";
|
||||
foreach( $styles as $style => $pattern )
|
||||
{
|
||||
$fmt = ut_nfmt_create( $locale, $style, $pattern );
|
||||
|
||||
if(!$fmt) {
|
||||
$str_res .= "Bad formatter!\n";
|
||||
continue;
|
||||
}
|
||||
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
|
||||
}
|
||||
}
|
||||
return $str_res;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
Locale is: en_US
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'\$1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
'USD1,234,567.89'
|
||||
|
||||
Locale is: ru_UA
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ?(грн\.|₴)'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь'
|
||||
'1 234 567.?'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
'1 234 567,89 UAH'
|
||||
|
||||
Locale is: de
|
||||
'1234567,89123457'
|
||||
'1.234.567,891'
|
||||
'(¤ )?1.234.567,89( ¤)?'
|
||||
'123\.456\.789 %'
|
||||
'1,23456789123457E6'
|
||||
'eine Million zweihundertvierunddreißigtausendfünfhundertsiebenundsechzig Komma acht neun eins zwei drei vier fünf sieben'
|
||||
'1.234.567.?'
|
||||
'1.234.567'
|
||||
'#####.###'
|
||||
'1.234.567,89 ¤¤'
|
||||
|
||||
Locale is: fr
|
||||
'1234567,89123457'
|
||||
'1 234 567,891'
|
||||
'1 234 567,89 ¤'
|
||||
'123 456 789 ?%'
|
||||
'1,23456789123457E6'
|
||||
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept'
|
||||
'1 234 567e'
|
||||
'1 234 567'
|
||||
'#####.###'
|
||||
'1 234 567,89 ¤¤'
|
||||
|
||||
Locale is: en_UK
|
||||
'1234567.89123457'
|
||||
'1,234,567.891'
|
||||
'¤1,234,567.89'
|
||||
'123,456,789%'
|
||||
'1.23456789123457E6'
|
||||
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
|
||||
'1,234,567(th|ᵗʰ)'
|
||||
'342:56:07'
|
||||
'#####.###'
|
||||
'¤¤1,234,567.89'
|
||||
@@ -2,6 +2,7 @@
|
||||
numfmt_get_locale()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
--TEST--
|
||||
numfmt_get_locale()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Get locale.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$locales = array(
|
||||
'en_UK',
|
||||
'en_US@California',
|
||||
'fr_CA',
|
||||
);
|
||||
|
||||
$loc_types = array(
|
||||
Locale::ACTUAL_LOCALE => 'actual',
|
||||
Locale::VALID_LOCALE => 'valid',
|
||||
);
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL );
|
||||
$res_str .= "$locale: ";
|
||||
foreach( $loc_types as $loc_type => $loc_type_name )
|
||||
$res_str .= sprintf( " %s=%s",
|
||||
$loc_type_name,
|
||||
dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) );
|
||||
$res_str .= "\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
en_UK: actual='en' valid='en'
|
||||
en_US@California: actual='en' valid='en'
|
||||
fr_CA: actual='fr' valid='fr_CA'
|
||||
@@ -1,8 +1,9 @@
|
||||
--TEST--
|
||||
locale_filter_matches.phpt() icu >= 4.8
|
||||
locale_filter_matches.phpt() icu >= 4.8 && icu < 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
--TEST--
|
||||
locale_filter_matches.phpt() ICU >= 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try parsing different Locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$loc_ranges = array(
|
||||
'de-de',
|
||||
'sl_IT',
|
||||
'sl_IT_Nedis',
|
||||
'jbo',
|
||||
'art-lojban',
|
||||
'sl_IT'
|
||||
);
|
||||
|
||||
$lang_tags = array(
|
||||
'de-DEVA',
|
||||
'de-DE-1996',
|
||||
'de-DE',
|
||||
'zh_Hans',
|
||||
'de-CH-1996',
|
||||
'sl_IT',
|
||||
'sl_IT_nedis-a-kirti-x-xyz',
|
||||
'sl_IT_rozaj',
|
||||
'sl_IT_NEDIS_ROJAZ_1901',
|
||||
'i-enochian',
|
||||
'sgn-CH-de',
|
||||
'art-lojban',
|
||||
'i-lux',
|
||||
'art-lojban',
|
||||
'jbo',
|
||||
'en_sl_IT'
|
||||
);
|
||||
|
||||
$res_str = '';
|
||||
$isCanonical = false;
|
||||
foreach($loc_ranges as $loc_range){
|
||||
foreach($lang_tags as $lang_tag){
|
||||
$res_str .="--------------\n";
|
||||
$result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical);
|
||||
$res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? ";
|
||||
if( $result){
|
||||
$res_str .= "YES\n";
|
||||
}else{
|
||||
$res_str .= "NO\n";
|
||||
}
|
||||
//canonicalized version
|
||||
$result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical));
|
||||
$can_loc_range = ut_loc_canonicalize($loc_range);
|
||||
$can_lang_tag = ut_loc_canonicalize($lang_tag);
|
||||
$res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? ";
|
||||
if( $result){
|
||||
$res_str .= "YES\n";
|
||||
}else{
|
||||
$res_str .= "NO\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res_str .= "\n";
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag de-DEVA ? NO
|
||||
loc_range:de_DE canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag de-DE-1996 ? YES
|
||||
loc_range:de_DE canonically matches lang_tag de_DE_1996 ? YES
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag de-DE ? YES
|
||||
loc_range:de_DE canonically matches lang_tag de_DE ? YES
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag zh_Hans ? NO
|
||||
loc_range:de_DE canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:de_DE canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag sl_IT ? NO
|
||||
loc_range:de_DE canonically matches lang_tag sl_IT ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
|
||||
loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag sl_IT_rozaj ? NO
|
||||
loc_range:de_DE canonically matches lang_tag sl_IT_ROZAJ ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag i-enochian ? NO
|
||||
loc_range:de_DE canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:de_DE canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag art-lojban ? NO
|
||||
loc_range:de_DE canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag i-lux ? NO
|
||||
loc_range:de_DE canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag art-lojban ? NO
|
||||
loc_range:de_DE canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag jbo ? NO
|
||||
loc_range:de_DE canonically matches lang_tag jbo ? NO
|
||||
--------------
|
||||
loc_range:de-de matches lang_tag en_sl_IT ? NO
|
||||
loc_range:de_DE canonically matches lang_tag en_SL_IT ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DEVA ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DE ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag zh_Hans ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag i-enochian ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag i-lux ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag jbo ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag jbo ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag en_sl_IT ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag de-DEVA ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag de-DE-1996 ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag de-DE ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag zh_Hans ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag sl_IT ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag sl_IT_rozaj ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_ROZAJ ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag i-enochian ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag i-lux ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag jbo ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis matches lang_tag en_sl_IT ? NO
|
||||
loc_range:sl_IT_NEDIS canonically matches lang_tag en_SL_IT ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag de-DEVA ? NO
|
||||
loc_range:jbo canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag de-DE-1996 ? NO
|
||||
loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag de-DE ? NO
|
||||
loc_range:jbo canonically matches lang_tag de_DE ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag zh_Hans ? NO
|
||||
loc_range:jbo canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag sl_IT ? NO
|
||||
loc_range:jbo canonically matches lang_tag sl_IT ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
|
||||
loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag sl_IT_rozaj ? NO
|
||||
loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag i-enochian ? NO
|
||||
loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag art-lojban ? NO
|
||||
loc_range:jbo canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag i-lux ? NO
|
||||
loc_range:jbo canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag art-lojban ? NO
|
||||
loc_range:jbo canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag jbo ? YES
|
||||
loc_range:jbo canonically matches lang_tag jbo ? YES
|
||||
--------------
|
||||
loc_range:jbo matches lang_tag en_sl_IT ? NO
|
||||
loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag de-DEVA ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag de-DE-1996 ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag de_DE_1996 ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag de-DE ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag de_DE ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag zh_Hans ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag sl_IT ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag sl_IT ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag sl_IT_rozaj ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag sl_IT_ROZAJ ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag i-enochian ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag art-lojban ? YES
|
||||
loc_range:art__LOJBAN canonically matches lang_tag art__LOJBAN ? YES
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag i-lux ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag art-lojban ? YES
|
||||
loc_range:art__LOJBAN canonically matches lang_tag art__LOJBAN ? YES
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag jbo ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag jbo ? NO
|
||||
--------------
|
||||
loc_range:art-lojban matches lang_tag en_sl_IT ? NO
|
||||
loc_range:art__LOJBAN canonically matches lang_tag en_SL_IT ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DEVA ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-DE ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag zh_Hans ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag i-enochian ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag i-lux ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag lb ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag art-lojban ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag jbo ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag jbo ? NO
|
||||
--------------
|
||||
loc_range:sl_IT matches lang_tag en_sl_IT ? NO
|
||||
loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
|
||||
@@ -1,8 +1,9 @@
|
||||
--TEST--
|
||||
locale_get_display_name() icu >= 4.8
|
||||
locale_get_display_name() icu >= 4.8 && icu < 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
--TEST--
|
||||
locale_get_display_name() icu >= 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try getting the display_name for different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str='';
|
||||
|
||||
$disp_locales=array('en','fr','de');
|
||||
|
||||
$locales = array(
|
||||
'sl_IT_nedis_KIRTI',
|
||||
'sl_IT_nedis-a-kirti-x-xyz',
|
||||
'sl_IT_rozaj',
|
||||
'sl_IT_NEDIS_ROJAZ_1901',
|
||||
'i-enochian',
|
||||
'zh-hakka',
|
||||
'zh-wuu',
|
||||
'i-tay',
|
||||
'sgn-BE-nl',
|
||||
'sgn-CH-de',
|
||||
'sl_IT_rozaj@currency=EUR',
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'Hindi',
|
||||
//Simple language subtag
|
||||
'de',
|
||||
'fr',
|
||||
'ja',
|
||||
'i-enochian', //(example of a grandfathered tag)
|
||||
//Language subtag plus Script subtag:
|
||||
'zh-Hant',
|
||||
'zh-Hans',
|
||||
'sr-Cyrl',
|
||||
'sr-Latn',
|
||||
//Language-Script-Region
|
||||
'zh-Hans-CN',
|
||||
'sr-Latn-CS',
|
||||
//Language-Variant
|
||||
'sl-rozaj',
|
||||
'sl-nedis',
|
||||
//Language-Region-Variant
|
||||
'de-CH-1901',
|
||||
'sl-IT-nedis',
|
||||
//Language-Script-Region-Variant
|
||||
'sl-Latn-IT-nedis',
|
||||
//Language-Region:
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-419',
|
||||
//Private use subtags:
|
||||
'de-CH-x-phonebk',
|
||||
'az-Arab-x-AZE-derbend',
|
||||
//Extended language subtags
|
||||
'zh-min',
|
||||
'zh-min-nan-Hant-CN',
|
||||
//Private use registry values
|
||||
'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern',
|
||||
'sr-Latn-QM',
|
||||
'sr-Qaaa-CS',
|
||||
/*Tags that use extensions (examples ONLY: extensions MUST be defined
|
||||
by revision or update to this document or by RFC): */
|
||||
'en-US-u-islamCal',
|
||||
'zh-CN-a-myExt-x-private',
|
||||
'en-a-myExt-b-another',
|
||||
//Some Invalid Tags:
|
||||
'de-419-DE',
|
||||
'a-DE',
|
||||
'ar-a-aaa-b-bbb-a-ccc'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$res_str .= "locale='$locale'\n";
|
||||
foreach( $disp_locales as $disp_locale )
|
||||
{
|
||||
$scr = ut_loc_get_display_name( $locale ,$disp_locale );
|
||||
$scr = str_replace(array('(', ')'), '#', $scr);
|
||||
$res_str .= "disp_locale=$disp_locale : display_name=$scr";
|
||||
$res_str .= "\n";
|
||||
}
|
||||
$res_str .= "-----------------\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
locale='sl_IT_nedis_KIRTI'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI#
|
||||
-----------------
|
||||
locale='sl_IT_nedis-a-kirti-x-xyz'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)#
|
||||
-----------------
|
||||
locale='sl_IT_NEDIS_ROJAZ_1901'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901#
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-hakka'
|
||||
disp_locale=en : display_name=Chinese( #HAKKA#)?
|
||||
disp_locale=fr : display_name=chinois( #HAKKA#)?
|
||||
disp_locale=de : display_name=Chinesisch( #HAKKA#)?
|
||||
-----------------
|
||||
locale='zh-wuu'
|
||||
disp_locale=en : display_name=Chinese #WUU#
|
||||
disp_locale=fr : display_name=chinois #WUU#
|
||||
disp_locale=de : display_name=Chinesisch #WUU#
|
||||
-----------------
|
||||
locale='i-tay'
|
||||
disp_locale=en : display_name=i-tay
|
||||
disp_locale=fr : display_name=i-tay
|
||||
disp_locale=de : display_name=i-tay
|
||||
-----------------
|
||||
locale='sgn-BE-nl'
|
||||
disp_locale=en : display_name=Sign Languages? #Belgium, NL#
|
||||
disp_locale=fr : display_name=langues? des signes #Belgique, NL#
|
||||
disp_locale=de : display_name=Gebärdensprache #Belgien, NL#
|
||||
-----------------
|
||||
locale='sgn-CH-de'
|
||||
disp_locale=en : display_name=Sign Languages? #Switzerland, DE#
|
||||
disp_locale=fr : display_name=langues? des signes #Suisse, DE#
|
||||
disp_locale=de : display_name=Gebärdensprache #Schweiz, DE#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj@currency=EUR'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, [Dd]evise=euro#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro#
|
||||
-----------------
|
||||
locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
disp_locale=en : display_name=Ukrainian #Ukraine, CALIFORNIA, [Cc]urrency#
|
||||
disp_locale=fr : display_name=ukrainien #Ukraine, CALIFORNIA, [Dd]evise#
|
||||
disp_locale=de : display_name=Ukrainisch #Ukraine, CALIFORNIA, Währung#
|
||||
-----------------
|
||||
locale='root'
|
||||
disp_locale=en : display_name=Root
|
||||
disp_locale=fr : display_name=racine
|
||||
disp_locale=de : display_name=[Rr]oot
|
||||
-----------------
|
||||
locale='uk@currency=EURO'
|
||||
disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO#
|
||||
disp_locale=fr : display_name=ukrainien #[Dd]evise=EURO#
|
||||
disp_locale=de : display_name=Ukrainisch #Währung=EURO#
|
||||
-----------------
|
||||
locale='Hindi'
|
||||
disp_locale=en : display_name=hindi
|
||||
disp_locale=fr : display_name=hindi
|
||||
disp_locale=de : display_name=hindi
|
||||
-----------------
|
||||
locale='de'
|
||||
disp_locale=en : display_name=German
|
||||
disp_locale=fr : display_name=allemand
|
||||
disp_locale=de : display_name=Deutsch
|
||||
-----------------
|
||||
locale='fr'
|
||||
disp_locale=en : display_name=French
|
||||
disp_locale=fr : display_name=français
|
||||
disp_locale=de : display_name=Französisch
|
||||
-----------------
|
||||
locale='ja'
|
||||
disp_locale=en : display_name=Japanese
|
||||
disp_locale=fr : display_name=japonais
|
||||
disp_locale=de : display_name=Japanisch
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-Hant'
|
||||
disp_locale=en : display_name=Chinese #Traditional#
|
||||
disp_locale=fr : display_name=chinois #traditionnel#
|
||||
disp_locale=de : display_name=Chinesisch #Traditionell#
|
||||
-----------------
|
||||
locale='zh-Hans'
|
||||
disp_locale=en : display_name=Chinese #Simplified#
|
||||
disp_locale=fr : display_name=chinois #simplifié#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht#
|
||||
-----------------
|
||||
locale='sr-Cyrl'
|
||||
disp_locale=en : display_name=Serbian #Cyrillic#
|
||||
disp_locale=fr : display_name=serbe #cyrillique#
|
||||
disp_locale=de : display_name=Serbisch #Kyrillisch#
|
||||
-----------------
|
||||
locale='sr-Latn'
|
||||
disp_locale=en : display_name=Serbian #Latin#
|
||||
disp_locale=fr : display_name=serbe #latin#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch#
|
||||
-----------------
|
||||
locale='zh-Hans-CN'
|
||||
disp_locale=en : display_name=Chinese #Simplified, China#
|
||||
disp_locale=fr : display_name=chinois #simplifié, Chine#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht, China#
|
||||
-----------------
|
||||
locale='sr-Latn-CS'
|
||||
disp_locale=en : display_name=Serbian #Latin, Serbia#
|
||||
disp_locale=fr : display_name=serbe #latin, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, Serbien#
|
||||
-----------------
|
||||
locale='sl-rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Resian#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)?
|
||||
-----------------
|
||||
locale='sl-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Natisone-Dialekt#
|
||||
-----------------
|
||||
locale='de-CH-1901'
|
||||
disp_locale=en : display_name=German #Switzerland, Traditional German orthography#
|
||||
disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)#
|
||||
-----------------
|
||||
locale='sl-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='sl-Latn-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='de-DE'
|
||||
disp_locale=en : display_name=German #Germany#
|
||||
disp_locale=fr : display_name=allemand #Allemagne#
|
||||
disp_locale=de : display_name=Deutsch #Deutschland#
|
||||
-----------------
|
||||
locale='en-US'
|
||||
disp_locale=en : display_name=English #United States#
|
||||
disp_locale=fr : display_name=anglais #États-Unis#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten#
|
||||
-----------------
|
||||
locale='es-419'
|
||||
disp_locale=en : display_name=Spanish #Latin America#
|
||||
disp_locale=fr : display_name=espagnol #Amérique latine#
|
||||
disp_locale=de : display_name=Spanisch #Lateinamerika#
|
||||
-----------------
|
||||
locale='de-CH-x-phonebk'
|
||||
disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk#
|
||||
disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk#
|
||||
-----------------
|
||||
locale='az-Arab-x-AZE-derbend'
|
||||
disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend#
|
||||
disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend#
|
||||
disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend#
|
||||
-----------------
|
||||
locale='zh-min'
|
||||
disp_locale=en : display_name=Chinese #MIN#
|
||||
disp_locale=fr : display_name=chinois #MIN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN#
|
||||
-----------------
|
||||
locale='zh-min-nan-Hant-CN'
|
||||
disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN#
|
||||
disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN#
|
||||
-----------------
|
||||
locale='x-whatever'
|
||||
disp_locale=en : display_name=x-whatever #Private-Use=whatever#
|
||||
disp_locale=fr : display_name=x-whatever #Usage privé=whatever#
|
||||
disp_locale=de : display_name=x-whatever #Privatnutzung=whatever#
|
||||
-----------------
|
||||
locale='qaa-Qaaa-QM-x-southern'
|
||||
disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern#
|
||||
disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern#
|
||||
disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern#
|
||||
-----------------
|
||||
locale='sr-Latn-QM'
|
||||
disp_locale=en : display_name=Serbian #Latin, QM#
|
||||
disp_locale=fr : display_name=serbe #latin, QM#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, QM#
|
||||
-----------------
|
||||
locale='sr-Qaaa-CS'
|
||||
disp_locale=en : display_name=Serbian #Qaaa, Serbia#
|
||||
disp_locale=fr : display_name=serbe #Qaaa, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Qaaa, Serbien#
|
||||
-----------------
|
||||
locale='en-US-u-islamCal'
|
||||
disp_locale=en : display_name=English #United States, attribute=islamcal#
|
||||
disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal#
|
||||
-----------------
|
||||
locale='zh-CN-a-myExt-x-private'
|
||||
disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private#
|
||||
disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private#
|
||||
disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private#
|
||||
-----------------
|
||||
locale='en-a-myExt-b-another'
|
||||
disp_locale=en : display_name=English #a=myext, b=another#
|
||||
disp_locale=fr : display_name=anglais #a=myext, b=another#
|
||||
disp_locale=de : display_name=Englisch #a=myext, b=another#
|
||||
-----------------
|
||||
locale='de-419-DE'
|
||||
disp_locale=en : display_name=German #Latin America, DE#
|
||||
disp_locale=fr : display_name=allemand #Amérique latine, DE#
|
||||
disp_locale=de : display_name=Deutsch #Lateinamerika, DE#
|
||||
-----------------
|
||||
locale='a-DE'
|
||||
disp_locale=en : display_name=a #Germany#
|
||||
disp_locale=fr : display_name=a #Allemagne#
|
||||
disp_locale=de : display_name=a #Deutschland#
|
||||
-----------------
|
||||
locale='ar-a-aaa-b-bbb-a-ccc'
|
||||
disp_locale=en : display_name=Arabic #a=aaa, b=bbb#
|
||||
disp_locale=fr : display_name=arabe #a=aaa, b=bbb#
|
||||
disp_locale=de : display_name=Arabisch #a=aaa, b=bbb#
|
||||
-----------------
|
||||
@@ -0,0 +1,343 @@
|
||||
--TEST--
|
||||
locale_get_display_name() icu >= 52.1 && icu < 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') >= 0) die('skip for ICU < 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try getting the display_name for different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str='';
|
||||
|
||||
$disp_locales=array('en','fr','de');
|
||||
|
||||
$locales = array(
|
||||
'sl_IT_nedis_KIRTI',
|
||||
'sl_IT_nedis-a-kirti-x-xyz',
|
||||
'sl_IT_rozaj',
|
||||
'sl_IT_NEDIS_ROJAZ_1901',
|
||||
'i-enochian',
|
||||
'zh-hakka',
|
||||
'zh-wuu',
|
||||
'i-tay',
|
||||
'sgn-BE-nl',
|
||||
'sgn-CH-de',
|
||||
'sl_IT_rozaj@currency=EUR',
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'Hindi',
|
||||
//Simple language subtag
|
||||
'de',
|
||||
'fr',
|
||||
'ja',
|
||||
'i-enochian', //(example of a grandfathered tag)
|
||||
//Language subtag plus Script subtag:
|
||||
'zh-Hant',
|
||||
'zh-Hans',
|
||||
'sr-Cyrl',
|
||||
'sr-Latn',
|
||||
//Language-Script-Region
|
||||
'zh-Hans-CN',
|
||||
'sr-Latn-CS',
|
||||
//Language-Variant
|
||||
'sl-rozaj',
|
||||
'sl-nedis',
|
||||
//Language-Region-Variant
|
||||
'de-CH-1901',
|
||||
'sl-IT-nedis',
|
||||
//Language-Script-Region-Variant
|
||||
'sl-Latn-IT-nedis',
|
||||
//Language-Region:
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-419',
|
||||
//Private use subtags:
|
||||
'de-CH-x-phonebk',
|
||||
'az-Arab-x-AZE-derbend',
|
||||
//Extended language subtags
|
||||
'zh-min',
|
||||
'zh-min-nan-Hant-CN',
|
||||
//Private use registry values
|
||||
'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern',
|
||||
'sr-Latn-QM',
|
||||
'sr-Qaaa-CS',
|
||||
/*Tags that use extensions (examples ONLY: extensions MUST be defined
|
||||
by revision or update to this document or by RFC): */
|
||||
'en-US-u-islamCal',
|
||||
'zh-CN-a-myExt-x-private',
|
||||
'en-a-myExt-b-another',
|
||||
//Some Invalid Tags:
|
||||
'de-419-DE',
|
||||
'a-DE',
|
||||
'ar-a-aaa-b-bbb-a-ccc'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$res_str .= "locale='$locale'\n";
|
||||
foreach( $disp_locales as $disp_locale )
|
||||
{
|
||||
$scr = ut_loc_get_display_name( $locale ,$disp_locale );
|
||||
$scr = str_replace(array('(', ')'), '#', $scr);
|
||||
$res_str .= "disp_locale=$disp_locale : display_name=$scr";
|
||||
$res_str .= "\n";
|
||||
}
|
||||
$res_str .= "-----------------\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
locale='sl_IT_nedis_KIRTI'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI#
|
||||
-----------------
|
||||
locale='sl_IT_nedis-a-kirti-x-xyz'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)#
|
||||
-----------------
|
||||
locale='sl_IT_NEDIS_ROJAZ_1901'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901#
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-hakka'
|
||||
disp_locale=en : display_name=Chinese( #HAKKA#)?
|
||||
disp_locale=fr : display_name=chinois( #HAKKA#)?
|
||||
disp_locale=de : display_name=Chinesisch( #HAKKA#)?
|
||||
-----------------
|
||||
locale='zh-wuu'
|
||||
disp_locale=en : display_name=Chinese #WUU#
|
||||
disp_locale=fr : display_name=chinois #WUU#
|
||||
disp_locale=de : display_name=Chinesisch #WUU#
|
||||
-----------------
|
||||
locale='i-tay'
|
||||
disp_locale=en : display_name=i-tay
|
||||
disp_locale=fr : display_name=i-tay
|
||||
disp_locale=de : display_name=i-tay
|
||||
-----------------
|
||||
locale='sgn-BE-nl'
|
||||
disp_locale=en : display_name=Sign Languages? #Belgium, NL#
|
||||
disp_locale=fr : display_name=langues? des signes #Belgique, NL#
|
||||
disp_locale=de : display_name=Gebärdensprache #Belgien, NL#
|
||||
-----------------
|
||||
locale='sgn-CH-de'
|
||||
disp_locale=en : display_name=Sign Languages? #Switzerland, DE#
|
||||
disp_locale=fr : display_name=langues? des signes #Suisse, DE#
|
||||
disp_locale=de : display_name=Gebärdensprache #Schweiz, DE#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj@currency=EUR'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, [Dd]evise=euro#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro#
|
||||
-----------------
|
||||
locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
disp_locale=en : display_name=
|
||||
disp_locale=fr : display_name=
|
||||
disp_locale=de : display_name=
|
||||
-----------------
|
||||
locale='root'
|
||||
disp_locale=en : display_name=Root
|
||||
disp_locale=fr : display_name=racine
|
||||
disp_locale=de : display_name=[Rr]oot
|
||||
-----------------
|
||||
locale='uk@currency=EURO'
|
||||
disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO#
|
||||
disp_locale=fr : display_name=ukrainien #[Dd]evise=EURO#
|
||||
disp_locale=de : display_name=Ukrainisch #Währung=EURO#
|
||||
-----------------
|
||||
locale='Hindi'
|
||||
disp_locale=en : display_name=hindi
|
||||
disp_locale=fr : display_name=hindi
|
||||
disp_locale=de : display_name=hindi
|
||||
-----------------
|
||||
locale='de'
|
||||
disp_locale=en : display_name=German
|
||||
disp_locale=fr : display_name=allemand
|
||||
disp_locale=de : display_name=Deutsch
|
||||
-----------------
|
||||
locale='fr'
|
||||
disp_locale=en : display_name=French
|
||||
disp_locale=fr : display_name=français
|
||||
disp_locale=de : display_name=Französisch
|
||||
-----------------
|
||||
locale='ja'
|
||||
disp_locale=en : display_name=Japanese
|
||||
disp_locale=fr : display_name=japonais
|
||||
disp_locale=de : display_name=Japanisch
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-Hant'
|
||||
disp_locale=en : display_name=Chinese #Traditional#
|
||||
disp_locale=fr : display_name=chinois #traditionnel#
|
||||
disp_locale=de : display_name=Chinesisch #Traditionell#
|
||||
-----------------
|
||||
locale='zh-Hans'
|
||||
disp_locale=en : display_name=Chinese #Simplified#
|
||||
disp_locale=fr : display_name=chinois #simplifié#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht#
|
||||
-----------------
|
||||
locale='sr-Cyrl'
|
||||
disp_locale=en : display_name=Serbian #Cyrillic#
|
||||
disp_locale=fr : display_name=serbe #cyrillique#
|
||||
disp_locale=de : display_name=Serbisch #Kyrillisch#
|
||||
-----------------
|
||||
locale='sr-Latn'
|
||||
disp_locale=en : display_name=Serbian #Latin#
|
||||
disp_locale=fr : display_name=serbe #latin#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch#
|
||||
-----------------
|
||||
locale='zh-Hans-CN'
|
||||
disp_locale=en : display_name=Chinese #Simplified, China#
|
||||
disp_locale=fr : display_name=chinois #simplifié, Chine#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht, China#
|
||||
-----------------
|
||||
locale='sr-Latn-CS'
|
||||
disp_locale=en : display_name=Serbian #Latin, Serbia#
|
||||
disp_locale=fr : display_name=serbe #latin, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, Serbien#
|
||||
-----------------
|
||||
locale='sl-rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Resian#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)?
|
||||
-----------------
|
||||
locale='sl-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Natisone-Dialekt#
|
||||
-----------------
|
||||
locale='de-CH-1901'
|
||||
disp_locale=en : display_name=German #Switzerland, Traditional German orthography#
|
||||
disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)#
|
||||
-----------------
|
||||
locale='sl-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='sl-Latn-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='de-DE'
|
||||
disp_locale=en : display_name=German #Germany#
|
||||
disp_locale=fr : display_name=allemand #Allemagne#
|
||||
disp_locale=de : display_name=Deutsch #Deutschland#
|
||||
-----------------
|
||||
locale='en-US'
|
||||
disp_locale=en : display_name=English #United States#
|
||||
disp_locale=fr : display_name=anglais #États-Unis#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten#
|
||||
-----------------
|
||||
locale='es-419'
|
||||
disp_locale=en : display_name=Spanish #Latin America#
|
||||
disp_locale=fr : display_name=espagnol #Amérique latine#
|
||||
disp_locale=de : display_name=Spanisch #Lateinamerika#
|
||||
-----------------
|
||||
locale='de-CH-x-phonebk'
|
||||
disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk#
|
||||
disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk#
|
||||
-----------------
|
||||
locale='az-Arab-x-AZE-derbend'
|
||||
disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend#
|
||||
disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend#
|
||||
disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend#
|
||||
-----------------
|
||||
locale='zh-min'
|
||||
disp_locale=en : display_name=Chinese #MIN#
|
||||
disp_locale=fr : display_name=chinois #MIN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN#
|
||||
-----------------
|
||||
locale='zh-min-nan-Hant-CN'
|
||||
disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN#
|
||||
disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN#
|
||||
-----------------
|
||||
locale='x-whatever'
|
||||
disp_locale=en : display_name=x-whatever #Private-Use=whatever#
|
||||
disp_locale=fr : display_name=x-whatever #Usage privé=whatever#
|
||||
disp_locale=de : display_name=x-whatever #Privatnutzung=whatever#
|
||||
-----------------
|
||||
locale='qaa-Qaaa-QM-x-southern'
|
||||
disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern#
|
||||
disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern#
|
||||
disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern#
|
||||
-----------------
|
||||
locale='sr-Latn-QM'
|
||||
disp_locale=en : display_name=Serbian #Latin, QM#
|
||||
disp_locale=fr : display_name=serbe #latin, QM#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, QM#
|
||||
-----------------
|
||||
locale='sr-Qaaa-CS'
|
||||
disp_locale=en : display_name=Serbian #Qaaa, Serbia#
|
||||
disp_locale=fr : display_name=serbe #Qaaa, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Qaaa, Serbien#
|
||||
-----------------
|
||||
locale='en-US-u-islamCal'
|
||||
disp_locale=en : display_name=English #United States, attribute=islamcal#
|
||||
disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal#
|
||||
-----------------
|
||||
locale='zh-CN-a-myExt-x-private'
|
||||
disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private#
|
||||
disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private#
|
||||
disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private#
|
||||
-----------------
|
||||
locale='en-a-myExt-b-another'
|
||||
disp_locale=en : display_name=English #a=myext, b=another#
|
||||
disp_locale=fr : display_name=anglais #a=myext, b=another#
|
||||
disp_locale=de : display_name=Englisch #a=myext, b=another#
|
||||
-----------------
|
||||
locale='de-419-DE'
|
||||
disp_locale=en : display_name=German #Latin America, DE#
|
||||
disp_locale=fr : display_name=allemand #Amérique latine, DE#
|
||||
disp_locale=de : display_name=Deutsch #Lateinamerika, DE#
|
||||
-----------------
|
||||
locale='a-DE'
|
||||
disp_locale=en : display_name=a #Germany#
|
||||
disp_locale=fr : display_name=a #Allemagne#
|
||||
disp_locale=de : display_name=a #Deutschland#
|
||||
-----------------
|
||||
locale='ar-a-aaa-b-bbb-a-ccc'
|
||||
disp_locale=en : display_name=Arabic #a=aaa, b=bbb#
|
||||
disp_locale=fr : display_name=arabe #a=aaa, b=bbb#
|
||||
disp_locale=de : display_name=Arabisch #a=aaa, b=bbb#
|
||||
-----------------
|
||||
@@ -0,0 +1,342 @@
|
||||
--TEST--
|
||||
locale_get_display_name() icu >= 53.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try getting the display_name for different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str='';
|
||||
|
||||
$disp_locales=array('en','fr','de');
|
||||
|
||||
$locales = array(
|
||||
'sl_IT_nedis_KIRTI',
|
||||
'sl_IT_nedis-a-kirti-x-xyz',
|
||||
'sl_IT_rozaj',
|
||||
'sl_IT_NEDIS_ROJAZ_1901',
|
||||
'i-enochian',
|
||||
'zh-hakka',
|
||||
'zh-wuu',
|
||||
'i-tay',
|
||||
'sgn-BE-nl',
|
||||
'sgn-CH-de',
|
||||
'sl_IT_rozaj@currency=EUR',
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'Hindi',
|
||||
//Simple language subtag
|
||||
'de',
|
||||
'fr',
|
||||
'ja',
|
||||
'i-enochian', //(example of a grandfathered tag)
|
||||
//Language subtag plus Script subtag:
|
||||
'zh-Hant',
|
||||
'zh-Hans',
|
||||
'sr-Cyrl',
|
||||
'sr-Latn',
|
||||
//Language-Script-Region
|
||||
'zh-Hans-CN',
|
||||
'sr-Latn-CS',
|
||||
//Language-Variant
|
||||
'sl-rozaj',
|
||||
'sl-nedis',
|
||||
//Language-Region-Variant
|
||||
'de-CH-1901',
|
||||
'sl-IT-nedis',
|
||||
//Language-Script-Region-Variant
|
||||
'sl-Latn-IT-nedis',
|
||||
//Language-Region:
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-419',
|
||||
//Private use subtags:
|
||||
'de-CH-x-phonebk',
|
||||
'az-Arab-x-AZE-derbend',
|
||||
//Extended language subtags
|
||||
'zh-min',
|
||||
'zh-min-nan-Hant-CN',
|
||||
//Private use registry values
|
||||
'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern',
|
||||
'sr-Latn-QM',
|
||||
'sr-Qaaa-CS',
|
||||
/*Tags that use extensions (examples ONLY: extensions MUST be defined
|
||||
by revision or update to this document or by RFC): */
|
||||
'en-US-u-islamCal',
|
||||
'zh-CN-a-myExt-x-private',
|
||||
'en-a-myExt-b-another',
|
||||
//Some Invalid Tags:
|
||||
'de-419-DE',
|
||||
'a-DE',
|
||||
'ar-a-aaa-b-bbb-a-ccc'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$res_str .= "locale='$locale'\n";
|
||||
foreach( $disp_locales as $disp_locale )
|
||||
{
|
||||
$scr = ut_loc_get_display_name( $locale ,$disp_locale );
|
||||
$scr = str_replace(array('(', ')'), '#', $scr);
|
||||
$res_str .= "disp_locale=$disp_locale : display_name=$scr";
|
||||
$res_str .= "\n";
|
||||
}
|
||||
$res_str .= "-----------------\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
locale='sl_IT_nedis_KIRTI'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI#
|
||||
-----------------
|
||||
locale='sl_IT_nedis-a-kirti-x-xyz'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)#
|
||||
-----------------
|
||||
locale='sl_IT_NEDIS_ROJAZ_1901'
|
||||
disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901#
|
||||
disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901#
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-hakka'
|
||||
disp_locale=en : display_name=Chinese( #HAKKA#)?
|
||||
disp_locale=fr : display_name=chinois( #HAKKA#)?
|
||||
disp_locale=de : display_name=Chinesisch( #HAKKA#)?
|
||||
-----------------
|
||||
locale='zh-wuu'
|
||||
disp_locale=en : display_name=Chinese #WUU#
|
||||
disp_locale=fr : display_name=chinois #WUU#
|
||||
disp_locale=de : display_name=Chinesisch #WUU#
|
||||
-----------------
|
||||
locale='i-tay'
|
||||
disp_locale=en : display_name=i-tay
|
||||
disp_locale=fr : display_name=i-tay
|
||||
disp_locale=de : display_name=i-tay
|
||||
-----------------
|
||||
locale='sgn-BE-nl'
|
||||
disp_locale=en : display_name=sgn #Belgium, NL#
|
||||
disp_locale=fr : display_name=sgn #Belgique, NL#
|
||||
disp_locale=de : display_name=sgn #Belgien, NL#
|
||||
-----------------
|
||||
locale='sgn-CH-de'
|
||||
disp_locale=en : display_name=sgn #Switzerland, DE#
|
||||
disp_locale=fr : display_name=sgn #Suisse, DE#
|
||||
disp_locale=de : display_name=sgn #Schweiz, DE#
|
||||
-----------------
|
||||
locale='sl_IT_rozaj@currency=EUR'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, [Dd]evise=euro#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro#
|
||||
-----------------
|
||||
locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
disp_locale=en : display_name=
|
||||
disp_locale=fr : display_name=
|
||||
disp_locale=de : display_name=
|
||||
-----------------
|
||||
locale='root'
|
||||
disp_locale=en : display_name=Root
|
||||
disp_locale=fr : display_name=racine
|
||||
disp_locale=de : display_name=[Rr]oot
|
||||
-----------------
|
||||
locale='uk@currency=EURO'
|
||||
disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO#
|
||||
disp_locale=fr : display_name=ukrainien #[Dd]evise=EURO#
|
||||
disp_locale=de : display_name=Ukrainisch #Währung=EURO#
|
||||
-----------------
|
||||
locale='Hindi'
|
||||
disp_locale=en : display_name=hindi
|
||||
disp_locale=fr : display_name=hindi
|
||||
disp_locale=de : display_name=hindi
|
||||
-----------------
|
||||
locale='de'
|
||||
disp_locale=en : display_name=German
|
||||
disp_locale=fr : display_name=allemand
|
||||
disp_locale=de : display_name=Deutsch
|
||||
-----------------
|
||||
locale='fr'
|
||||
disp_locale=en : display_name=French
|
||||
disp_locale=fr : display_name=français
|
||||
disp_locale=de : display_name=Französisch
|
||||
-----------------
|
||||
locale='ja'
|
||||
disp_locale=en : display_name=Japanese
|
||||
disp_locale=fr : display_name=japonais
|
||||
disp_locale=de : display_name=Japanisch
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_name=i-enochian #Private-Use=i-enochian#
|
||||
disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian#
|
||||
disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian#
|
||||
-----------------
|
||||
locale='zh-Hant'
|
||||
disp_locale=en : display_name=Chinese #Traditional#
|
||||
disp_locale=fr : display_name=chinois #traditionnel#
|
||||
disp_locale=de : display_name=Chinesisch #Traditionell#
|
||||
-----------------
|
||||
locale='zh-Hans'
|
||||
disp_locale=en : display_name=Chinese #Simplified#
|
||||
disp_locale=fr : display_name=chinois #simplifié#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht#
|
||||
-----------------
|
||||
locale='sr-Cyrl'
|
||||
disp_locale=en : display_name=Serbian #Cyrillic#
|
||||
disp_locale=fr : display_name=serbe #cyrillique#
|
||||
disp_locale=de : display_name=Serbisch #Kyrillisch#
|
||||
-----------------
|
||||
locale='sr-Latn'
|
||||
disp_locale=en : display_name=Serbian #Latin#
|
||||
disp_locale=fr : display_name=serbe #latin#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch#
|
||||
-----------------
|
||||
locale='zh-Hans-CN'
|
||||
disp_locale=en : display_name=Chinese #Simplified, China#
|
||||
disp_locale=fr : display_name=chinois #simplifié, Chine#
|
||||
disp_locale=de : display_name=Chinesisch #Vereinfacht, China#
|
||||
-----------------
|
||||
locale='sr-Latn-CS'
|
||||
disp_locale=en : display_name=Serbian #Latin, Serbia#
|
||||
disp_locale=fr : display_name=serbe #latin, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, Serbien#
|
||||
-----------------
|
||||
locale='sl-rozaj'
|
||||
disp_locale=en : display_name=Slovenian #Resian#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Resia#
|
||||
disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)?
|
||||
-----------------
|
||||
locale='sl-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Natisone-Dialekt#
|
||||
-----------------
|
||||
locale='de-CH-1901'
|
||||
disp_locale=en : display_name=German #Switzerland, Traditional German orthography#
|
||||
disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)#
|
||||
-----------------
|
||||
locale='sl-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='sl-Latn-IT-nedis'
|
||||
disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect#
|
||||
disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone#
|
||||
disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)#
|
||||
-----------------
|
||||
locale='de-DE'
|
||||
disp_locale=en : display_name=German #Germany#
|
||||
disp_locale=fr : display_name=allemand #Allemagne#
|
||||
disp_locale=de : display_name=Deutsch #Deutschland#
|
||||
-----------------
|
||||
locale='en-US'
|
||||
disp_locale=en : display_name=English #United States#
|
||||
disp_locale=fr : display_name=anglais #États-Unis#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten#
|
||||
-----------------
|
||||
locale='es-419'
|
||||
disp_locale=en : display_name=Spanish #Latin America#
|
||||
disp_locale=fr : display_name=espagnol #Amérique latine#
|
||||
disp_locale=de : display_name=Spanisch #Lateinamerika#
|
||||
-----------------
|
||||
locale='de-CH-x-phonebk'
|
||||
disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk#
|
||||
disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk#
|
||||
disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk#
|
||||
-----------------
|
||||
locale='az-Arab-x-AZE-derbend'
|
||||
disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend#
|
||||
disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend#
|
||||
disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend#
|
||||
-----------------
|
||||
locale='zh-min'
|
||||
disp_locale=en : display_name=Chinese #MIN#
|
||||
disp_locale=fr : display_name=chinois #MIN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN#
|
||||
-----------------
|
||||
locale='zh-min-nan-Hant-CN'
|
||||
disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN#
|
||||
disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN#
|
||||
disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN#
|
||||
-----------------
|
||||
locale='x-whatever'
|
||||
disp_locale=en : display_name=x-whatever #Private-Use=whatever#
|
||||
disp_locale=fr : display_name=x-whatever #Usage privé=whatever#
|
||||
disp_locale=de : display_name=x-whatever #Privatnutzung=whatever#
|
||||
-----------------
|
||||
locale='qaa-Qaaa-QM-x-southern'
|
||||
disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern#
|
||||
disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern#
|
||||
disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern#
|
||||
-----------------
|
||||
locale='sr-Latn-QM'
|
||||
disp_locale=en : display_name=Serbian #Latin, QM#
|
||||
disp_locale=fr : display_name=serbe #latin, QM#
|
||||
disp_locale=de : display_name=Serbisch #Lateinisch, QM#
|
||||
-----------------
|
||||
locale='sr-Qaaa-CS'
|
||||
disp_locale=en : display_name=Serbian #Qaaa, Serbia#
|
||||
disp_locale=fr : display_name=serbe #Qaaa, Serbie#
|
||||
disp_locale=de : display_name=Serbisch #Qaaa, Serbien#
|
||||
-----------------
|
||||
locale='en-US-u-islamCal'
|
||||
disp_locale=en : display_name=English #United States, attribute=islamcal#
|
||||
disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal#
|
||||
disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal#
|
||||
-----------------
|
||||
locale='zh-CN-a-myExt-x-private'
|
||||
disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private#
|
||||
disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private#
|
||||
disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private#
|
||||
-----------------
|
||||
locale='en-a-myExt-b-another'
|
||||
disp_locale=en : display_name=English #a=myext, b=another#
|
||||
disp_locale=fr : display_name=anglais #a=myext, b=another#
|
||||
disp_locale=de : display_name=Englisch #a=myext, b=another#
|
||||
-----------------
|
||||
locale='de-419-DE'
|
||||
disp_locale=en : display_name=German #Latin America, DE#
|
||||
disp_locale=fr : display_name=allemand #Amérique latine, DE#
|
||||
disp_locale=de : display_name=Deutsch #Lateinamerika, DE#
|
||||
-----------------
|
||||
locale='a-DE'
|
||||
disp_locale=en : display_name=a #Germany#
|
||||
disp_locale=fr : display_name=a #Allemagne#
|
||||
disp_locale=de : display_name=a #Deutschland#
|
||||
-----------------
|
||||
locale='ar-a-aaa-b-bbb-a-ccc'
|
||||
disp_locale=en : display_name=Arabic #a=aaa, b=bbb#
|
||||
disp_locale=fr : display_name=arabe #a=aaa, b=bbb#
|
||||
disp_locale=de : display_name=Arabisch #a=aaa, b=bbb#
|
||||
-----------------
|
||||
@@ -1,8 +1,9 @@
|
||||
--TEST--
|
||||
locale_get_display_region() icu >= 4.8
|
||||
locale_get_display_region() icu >= 4.8 && icu < 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
--TEST--
|
||||
locale_get_display_region() icu >= 51.2
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try getting the display_region for different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$disp_locales=array('en','fr','de');
|
||||
|
||||
$locales = array(
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'Hindi',
|
||||
//Simple language subtag
|
||||
'de',
|
||||
'fr',
|
||||
'ja',
|
||||
'i-enochian', //(example of a grandfathered tag)
|
||||
//Language subtag plus Script subtag:
|
||||
'zh-Hant',
|
||||
'zh-Hans',
|
||||
'sr-Cyrl',
|
||||
'sr-Latn',
|
||||
//Language-Script-Region
|
||||
'zh-Hans-CN',
|
||||
'sr-Latn-CS',
|
||||
//Language-Variant
|
||||
'sl-rozaj',
|
||||
'sl-nedis',
|
||||
//Language-Region-Variant
|
||||
'de-CH-1901',
|
||||
'sl-IT-nedis',
|
||||
//Language-Script-Region-Variant
|
||||
'sl-Latn-IT-nedis',
|
||||
//Language-Region:
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-419',
|
||||
//Private use subtags:
|
||||
'de-CH-x-phonebk',
|
||||
'az-Arab-x-AZE-derbend',
|
||||
//Extended language subtags
|
||||
'zh-min',
|
||||
'zh-min-nan-Hant-CN',
|
||||
//Private use registry values
|
||||
'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern',
|
||||
'sr-Latn-QM',
|
||||
'sr-Qaaa-CS',
|
||||
/*Tags that use extensions (examples ONLY: extensions MUST be defined
|
||||
by revision or update to this document or by RFC): */
|
||||
'en-US-u-islamCal',
|
||||
'zh-CN-a-myExt-x-private',
|
||||
'en-a-myExt-b-another',
|
||||
//Some Invalid Tags:
|
||||
'de-419-DE',
|
||||
'a-DE',
|
||||
'ar-a-aaa-b-bbb-a-ccc'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$res_str .= "locale='$locale'\n";
|
||||
foreach( $disp_locales as $disp_locale )
|
||||
{
|
||||
$scr = ut_loc_get_display_region( $locale ,$disp_locale );
|
||||
$res_str .= "disp_locale=$disp_locale : display_region=$scr";
|
||||
$res_str .= "\n";
|
||||
}
|
||||
$res_str .= "-----------------\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
disp_locale=en : display_region=Ukraine
|
||||
disp_locale=fr : display_region=Ukraine
|
||||
disp_locale=de : display_region=Ukraine
|
||||
-----------------
|
||||
locale='root'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='uk@currency=EURO'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='Hindi'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='de'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='fr'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='ja'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='zh-Hant'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='zh-Hans'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='sr-Cyrl'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='sr-Latn'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='zh-Hans-CN'
|
||||
disp_locale=en : display_region=China
|
||||
disp_locale=fr : display_region=Chine
|
||||
disp_locale=de : display_region=China
|
||||
-----------------
|
||||
locale='sr-Latn-CS'
|
||||
disp_locale=en : display_region=Serbia
|
||||
disp_locale=fr : display_region=Serbie
|
||||
disp_locale=de : display_region=Serbien
|
||||
-----------------
|
||||
locale='sl-rozaj'
|
||||
disp_locale=en : display_region=(ROZAJ)?
|
||||
disp_locale=fr : display_region=(ROZAJ)?
|
||||
disp_locale=de : display_region=(ROZAJ)?
|
||||
-----------------
|
||||
locale='sl-nedis'
|
||||
disp_locale=en : display_region=(NEDIS)?
|
||||
disp_locale=fr : display_region=(NEDIS)?
|
||||
disp_locale=de : display_region=(NEDIS)?
|
||||
-----------------
|
||||
locale='de-CH-1901'
|
||||
disp_locale=en : display_region=Switzerland
|
||||
disp_locale=fr : display_region=Suisse
|
||||
disp_locale=de : display_region=Schweiz
|
||||
-----------------
|
||||
locale='sl-IT-nedis'
|
||||
disp_locale=en : display_region=Italy
|
||||
disp_locale=fr : display_region=Italie
|
||||
disp_locale=de : display_region=Italien
|
||||
-----------------
|
||||
locale='sl-Latn-IT-nedis'
|
||||
disp_locale=en : display_region=Italy
|
||||
disp_locale=fr : display_region=Italie
|
||||
disp_locale=de : display_region=Italien
|
||||
-----------------
|
||||
locale='de-DE'
|
||||
disp_locale=en : display_region=Germany
|
||||
disp_locale=fr : display_region=Allemagne
|
||||
disp_locale=de : display_region=Deutschland
|
||||
-----------------
|
||||
locale='en-US'
|
||||
disp_locale=en : display_region=United States
|
||||
disp_locale=fr : display_region=États-Unis
|
||||
disp_locale=de : display_region=Vereinigte Staaten
|
||||
-----------------
|
||||
locale='es-419'
|
||||
disp_locale=en : display_region=Latin America
|
||||
disp_locale=fr : display_region=Amérique latine
|
||||
disp_locale=de : display_region=Lateinamerika
|
||||
-----------------
|
||||
locale='de-CH-x-phonebk'
|
||||
disp_locale=en : display_region=Switzerland
|
||||
disp_locale=fr : display_region=Suisse
|
||||
disp_locale=de : display_region=Schweiz
|
||||
-----------------
|
||||
locale='az-Arab-x-AZE-derbend'
|
||||
disp_locale=en : display_region=X?
|
||||
disp_locale=fr : display_region=X?
|
||||
disp_locale=de : display_region=X?
|
||||
-----------------
|
||||
locale='zh-min'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='zh-min-nan-Hant-CN'
|
||||
disp_locale=en : display_region=MIN
|
||||
disp_locale=fr : display_region=MIN
|
||||
disp_locale=de : display_region=MIN
|
||||
-----------------
|
||||
locale='x-whatever'
|
||||
disp_locale=en : display_region=
|
||||
disp_locale=fr : display_region=
|
||||
disp_locale=de : display_region=
|
||||
-----------------
|
||||
locale='qaa-Qaaa-QM-x-southern'
|
||||
disp_locale=en : display_region=QM
|
||||
disp_locale=fr : display_region=QM
|
||||
disp_locale=de : display_region=QM
|
||||
-----------------
|
||||
locale='sr-Latn-QM'
|
||||
disp_locale=en : display_region=QM
|
||||
disp_locale=fr : display_region=QM
|
||||
disp_locale=de : display_region=QM
|
||||
-----------------
|
||||
locale='sr-Qaaa-CS'
|
||||
disp_locale=en : display_region=Serbia
|
||||
disp_locale=fr : display_region=Serbie
|
||||
disp_locale=de : display_region=Serbien
|
||||
-----------------
|
||||
locale='en-US-u-islamCal'
|
||||
disp_locale=en : display_region=United States
|
||||
disp_locale=fr : display_region=États-Unis
|
||||
disp_locale=de : display_region=Vereinigte Staaten
|
||||
-----------------
|
||||
locale='zh-CN-a-myExt-x-private'
|
||||
disp_locale=en : display_region=China
|
||||
disp_locale=fr : display_region=Chine
|
||||
disp_locale=de : display_region=China
|
||||
-----------------
|
||||
locale='en-a-myExt-b-another'
|
||||
disp_locale=en : display_region=A?
|
||||
disp_locale=fr : display_region=A?
|
||||
disp_locale=de : display_region=A?
|
||||
-----------------
|
||||
locale='de-419-DE'
|
||||
disp_locale=en : display_region=Latin America
|
||||
disp_locale=fr : display_region=Amérique latine
|
||||
disp_locale=de : display_region=Lateinamerika
|
||||
-----------------
|
||||
locale='a-DE'
|
||||
disp_locale=en : display_region=Germany
|
||||
disp_locale=fr : display_region=Allemagne
|
||||
disp_locale=de : display_region=Deutschland
|
||||
-----------------
|
||||
locale='ar-a-aaa-b-bbb-a-ccc'
|
||||
disp_locale=en : display_region=A?
|
||||
disp_locale=fr : display_region=A?
|
||||
disp_locale=de : display_region=A?
|
||||
-----------------
|
||||
@@ -2,7 +2,7 @@
|
||||
locale_get_display_script() icu >= 49
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '49') < 0) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '49') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
--TEST--
|
||||
locale_get_display_script() icu >= 52.1
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if(version_compare(INTL_ICU_VERSION, '52.1') < 0) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try getting the display_script for different locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$res_str = '';
|
||||
|
||||
$disp_locales=array('en','fr','de');
|
||||
|
||||
$locales = array(
|
||||
'uk-ua_CALIFORNIA@currency=;currency=GRN',
|
||||
'root',
|
||||
'uk@currency=EURO',
|
||||
'Hindi',
|
||||
//Simple language subtag
|
||||
'de',
|
||||
'fr',
|
||||
'ja',
|
||||
'i-enochian', //(example of a grandfathered tag)
|
||||
//Language subtag plus Script subtag:
|
||||
'zh-Hant',
|
||||
'zh-Hans',
|
||||
'sr-Cyrl',
|
||||
'sr-Latn',
|
||||
//Language-Script-Region
|
||||
'zh-Hans-CN',
|
||||
'sr-Latn-CS',
|
||||
//Language-Variant
|
||||
'sl-rozaj',
|
||||
'sl-nedis',
|
||||
//Language-Region-Variant
|
||||
'de-CH-1901',
|
||||
'sl-IT-nedis',
|
||||
//Language-Script-Region-Variant
|
||||
'sl-Latn-IT-nedis',
|
||||
//Language-Region:
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-419',
|
||||
//Private use subtags:
|
||||
'de-CH-x-phonebk',
|
||||
'az-Arab-x-AZE-derbend',
|
||||
//Extended language subtags
|
||||
'zh-min',
|
||||
'zh-min-nan-Hant-CN',
|
||||
//Private use registry values
|
||||
'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern',
|
||||
'sr-Latn-QM',
|
||||
'sr-Qaaa-CS',
|
||||
/*Tags that use extensions (examples ONLY: extensions MUST be defined
|
||||
by revision or update to this document or by RFC): */
|
||||
'en-US-u-islamCal',
|
||||
'zh-CN-a-myExt-x-private',
|
||||
'en-a-myExt-b-another',
|
||||
//Some Invalid Tags:
|
||||
'de-419-DE',
|
||||
'a-DE',
|
||||
'ar-a-aaa-b-bbb-a-ccc'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
|
||||
foreach( $locales as $locale )
|
||||
{
|
||||
$res_str .= "locale='$locale'\n";
|
||||
foreach( $disp_locales as $disp_locale )
|
||||
{
|
||||
$scr = ut_loc_get_display_script( $locale ,$disp_locale );
|
||||
$res_str .= "disp_locale=$disp_locale : display_script=$scr";
|
||||
$res_str .= "\n";
|
||||
}
|
||||
$res_str .= "-----------------\n";
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
locale='uk-ua_CALIFORNIA@currency=;currency=GRN'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='root'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='uk@currency=EURO'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='Hindi'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='de'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='fr'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='ja'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='i-enochian'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='zh-Hant'
|
||||
disp_locale=en : display_script=Traditional Han
|
||||
disp_locale=fr : display_script=sinogrammes traditionnels
|
||||
disp_locale=de : display_script=Traditionelles Chinesisch
|
||||
-----------------
|
||||
locale='zh-Hans'
|
||||
disp_locale=en : display_script=Simplified Han
|
||||
disp_locale=fr : display_script=sinogrammes simplifiés
|
||||
disp_locale=de : display_script=Vereinfachtes Chinesisch
|
||||
-----------------
|
||||
locale='sr-Cyrl'
|
||||
disp_locale=en : display_script=Cyrillic
|
||||
disp_locale=fr : display_script=cyrillique
|
||||
disp_locale=de : display_script=Kyrillisch
|
||||
-----------------
|
||||
locale='sr-Latn'
|
||||
disp_locale=en : display_script=Latin
|
||||
disp_locale=fr : display_script=latin
|
||||
disp_locale=de : display_script=Lateinisch
|
||||
-----------------
|
||||
locale='zh-Hans-CN'
|
||||
disp_locale=en : display_script=Simplified Han
|
||||
disp_locale=fr : display_script=sinogrammes simplifiés
|
||||
disp_locale=de : display_script=Vereinfachtes Chinesisch
|
||||
-----------------
|
||||
locale='sr-Latn-CS'
|
||||
disp_locale=en : display_script=Latin
|
||||
disp_locale=fr : display_script=latin
|
||||
disp_locale=de : display_script=Lateinisch
|
||||
-----------------
|
||||
locale='sl-rozaj'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='sl-nedis'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='de-CH-1901'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='sl-IT-nedis'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='sl-Latn-IT-nedis'
|
||||
disp_locale=en : display_script=Latin
|
||||
disp_locale=fr : display_script=latin
|
||||
disp_locale=de : display_script=Lateinisch
|
||||
-----------------
|
||||
locale='de-DE'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='en-US'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='es-419'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='de-CH-x-phonebk'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='az-Arab-x-AZE-derbend'
|
||||
disp_locale=en : display_script=Arabic
|
||||
disp_locale=fr : display_script=arabe
|
||||
disp_locale=de : display_script=Arabisch
|
||||
-----------------
|
||||
locale='zh-min'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='zh-min-nan-Hant-CN'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='x-whatever'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='qaa-Qaaa-QM-x-southern'
|
||||
disp_locale=en : display_script=Qaaa
|
||||
disp_locale=fr : display_script=Qaaa
|
||||
disp_locale=de : display_script=Qaaa
|
||||
-----------------
|
||||
locale='sr-Latn-QM'
|
||||
disp_locale=en : display_script=Latin
|
||||
disp_locale=fr : display_script=latin
|
||||
disp_locale=de : display_script=Lateinisch
|
||||
-----------------
|
||||
locale='sr-Qaaa-CS'
|
||||
disp_locale=en : display_script=Qaaa
|
||||
disp_locale=fr : display_script=Qaaa
|
||||
disp_locale=de : display_script=Qaaa
|
||||
-----------------
|
||||
locale='en-US-u-islamCal'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='zh-CN-a-myExt-x-private'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='en-a-myExt-b-another'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='de-419-DE'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='a-DE'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
locale='ar-a-aaa-b-bbb-a-ccc'
|
||||
disp_locale=en : display_script=
|
||||
disp_locale=fr : display_script=
|
||||
disp_locale=de : display_script=
|
||||
-----------------
|
||||
@@ -2,6 +2,7 @@
|
||||
locale_lookup.phpt()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
--TEST--
|
||||
locale_lookup.phpt()
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Try parsing different Locales
|
||||
* with Procedural and Object methods.
|
||||
*/
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$loc_ranges = array(
|
||||
'de-de',
|
||||
'sl_IT',
|
||||
'sl_IT_Nedis',
|
||||
'jbo',
|
||||
'art-lojban'
|
||||
);
|
||||
|
||||
$lang_tags = array(
|
||||
'de-DEVA',
|
||||
'de-DE-1996',
|
||||
'de-DE',
|
||||
'zh_Hans',
|
||||
'de-CH-1996',
|
||||
'sl_IT',
|
||||
'sl_IT_nedis-a-kirti-x-xyz',
|
||||
'sl_IT_rozaj',
|
||||
'sl_IT_NEDIS_ROJAZ_1901',
|
||||
'i-enochian',
|
||||
'sgn-CH-de',
|
||||
'art-lojban',
|
||||
'i-lux',
|
||||
'art-lojban',
|
||||
'jbo',
|
||||
'en_sl_IT',
|
||||
'zh-Hant-CN-x-prv1-prv2'
|
||||
);
|
||||
|
||||
|
||||
$res_str = '';
|
||||
$isCanonical = false;
|
||||
|
||||
foreach($loc_ranges as $loc_range){
|
||||
$res_str .="--------------\n";
|
||||
$result= ut_loc_locale_lookup( $lang_tags , $loc_range,$isCanonical,"en_US");
|
||||
$comma_arr =implode(",",$lang_tags);
|
||||
$res_str .= "loc_range:$loc_range \nlang_tags: $comma_arr\n";
|
||||
$res_str .= "\nlookup result:$result\n";
|
||||
//canonicalized version
|
||||
$result= ut_loc_locale_lookup( $lang_tags , $loc_range,!($isCanonical),"en_US");
|
||||
$can_loc_range = ut_loc_canonicalize($loc_range);
|
||||
$res_str .= "Canonical lookup result:$result\n";
|
||||
|
||||
}
|
||||
|
||||
$res_str .= "\n";
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
ut_run();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
--------------
|
||||
loc_range:de-de
|
||||
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
|
||||
|
||||
lookup result:de-DE
|
||||
Canonical lookup result:de_de
|
||||
--------------
|
||||
loc_range:sl_IT
|
||||
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
|
||||
|
||||
lookup result:sl_IT
|
||||
Canonical lookup result:sl_it
|
||||
--------------
|
||||
loc_range:sl_IT_Nedis
|
||||
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
|
||||
|
||||
lookup result:sl_IT
|
||||
Canonical lookup result:sl_it
|
||||
--------------
|
||||
loc_range:jbo
|
||||
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
|
||||
|
||||
lookup result:jbo
|
||||
Canonical lookup result:jbo
|
||||
--------------
|
||||
loc_range:art-lojban
|
||||
lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2
|
||||
|
||||
lookup result:art-lojban
|
||||
Canonical lookup result:art__lojban
|
||||
@@ -3,11 +3,9 @@ ResourceBundle constructor bundle accepts NULL for first two arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
|
||||
die('skip ICU >= 4.8 only');
|
||||
<?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '4.8') < 0) die('skip ICU >= 4.8 only'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
ResourceBundle constructor bundle accepts NULL for first two arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$r = new ResourceBundle('en_US', NULL);
|
||||
$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
|
||||
var_dump($c);
|
||||
|
||||
ini_set('intl.default_locale', 'pt_PT');
|
||||
$r = new ResourceBundle(NULL, NULL);
|
||||
$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
|
||||
var_dump($c);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(14) "h:mm:ss a zzzz"
|
||||
string(13) "HH:mm:ss zzzz"
|
||||
==DONE==
|
||||
+10
-8
@@ -219,7 +219,7 @@ static inline void json_pretty_print_indent(smart_str *buf, int options TSRMLS_D
|
||||
|
||||
static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int i, r;
|
||||
int i, r, need_comma = 0;
|
||||
HashTable *myht;
|
||||
|
||||
if (Z_TYPE_PP(val) == IS_ARRAY) {
|
||||
@@ -242,7 +242,6 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
smart_str_appendc(buf, '{');
|
||||
}
|
||||
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
++JSON_G(encoder_depth);
|
||||
|
||||
i = myht ? zend_hash_num_elements(myht) : 0;
|
||||
@@ -255,7 +254,6 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
uint key_len;
|
||||
HashPosition pos;
|
||||
HashTable *tmp_ht;
|
||||
int need_comma = 0;
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(myht, &pos);
|
||||
for (;; zend_hash_move_forward_ex(myht, &pos)) {
|
||||
@@ -272,11 +270,11 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
if (r == PHP_JSON_OUTPUT_ARRAY) {
|
||||
if (need_comma) {
|
||||
smart_str_appendc(buf, ',');
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
} else {
|
||||
need_comma = 1;
|
||||
}
|
||||
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
php_json_encode(buf, *data, options TSRMLS_CC);
|
||||
} else if (r == PHP_JSON_OUTPUT_OBJECT) {
|
||||
@@ -291,11 +289,11 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
|
||||
if (need_comma) {
|
||||
smart_str_appendc(buf, ',');
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
} else {
|
||||
need_comma = 1;
|
||||
}
|
||||
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
|
||||
json_escape_string(buf, key, key_len - 1, options & ~PHP_JSON_NUMERIC_CHECK TSRMLS_CC);
|
||||
@@ -307,11 +305,11 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
} else {
|
||||
if (need_comma) {
|
||||
smart_str_appendc(buf, ',');
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
} else {
|
||||
need_comma = 1;
|
||||
}
|
||||
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
|
||||
smart_str_appendc(buf, '"');
|
||||
@@ -333,8 +331,12 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
}
|
||||
|
||||
--JSON_G(encoder_depth);
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
|
||||
/* Only keep closing bracket on same line for empty arrays/objects */
|
||||
if (need_comma) {
|
||||
json_pretty_print_char(buf, options, '\n' TSRMLS_CC);
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (r == PHP_JSON_OUTPUT_ARRAY) {
|
||||
smart_str_appendc(buf, ']');
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #66021 (Blank line inside empty array/object when JSON_PRETTY_PRINT is set)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("json")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Foo {
|
||||
private $bar = 'baz';
|
||||
}
|
||||
|
||||
echo json_encode([[], (object)[], new Foo], JSON_PRETTY_PRINT), "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
[
|
||||
[],
|
||||
{},
|
||||
{}
|
||||
]
|
||||
@@ -399,6 +399,16 @@ PHP_FUNCTION(ldap_bind)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "DN contains a null byte");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ldap_bind_pw != NULL && memchr(ldap_bind_pw, '\0', ldap_bind_pwlen) != NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Password contains a null byte");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
|
||||
|
||||
if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) {
|
||||
|
||||
+8
-1
@@ -176,8 +176,11 @@ void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC)
|
||||
php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE);
|
||||
/* Clean output bind */
|
||||
php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT);
|
||||
#endif
|
||||
|
||||
if (stmt->link_handle) {
|
||||
zend_objects_store_del_ref_by_handle(stmt->link_handle TSRMLS_CC);
|
||||
}
|
||||
#endif
|
||||
if (stmt->query) {
|
||||
efree(stmt->query);
|
||||
}
|
||||
@@ -1055,6 +1058,10 @@ PHP_FUNCTION(mysqli_stmt_construct)
|
||||
efree(stmt);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#ifndef MYSQLI_USE_MYSQLND
|
||||
stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
|
||||
zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
||||
mysqli_resource->ptr = (void *)stmt;
|
||||
|
||||
@@ -1840,6 +1840,10 @@ PHP_FUNCTION(mysqli_prepare)
|
||||
efree(stmt);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#ifndef MYSQLI_USE_MYSQLND
|
||||
stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
|
||||
zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
||||
mysqli_resource->ptr = (void *)stmt;
|
||||
@@ -2368,6 +2372,10 @@ PHP_FUNCTION(mysqli_stmt_init)
|
||||
efree(stmt);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#ifndef MYSQLI_USE_MYSQLND
|
||||
stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
|
||||
zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
||||
mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
|
||||
|
||||
@@ -116,6 +116,10 @@ typedef struct {
|
||||
BIND_BUFFER param;
|
||||
BIND_BUFFER result;
|
||||
char *query;
|
||||
#ifndef MYSQLI_USE_MYSQLND
|
||||
/* used to manage refcount with libmysql (already implement in mysqlnd) */
|
||||
zend_object_handle link_handle;
|
||||
#endif
|
||||
} MY_STMT;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #66762 mysqli@libmysql segfault in mysqli_stmt::bind_result() when link closed
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
require_once('skipifconnectfailure.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("connect.inc");
|
||||
|
||||
$mysqli = new mysqli($host, $user, $passwd, $db);
|
||||
|
||||
$read_stmt = $mysqli->prepare("SELECT 1");
|
||||
|
||||
var_dump($read_stmt->bind_result($data));
|
||||
|
||||
unset($mysqli);
|
||||
var_dump($read_stmt->bind_result($data));
|
||||
|
||||
?>
|
||||
done!
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
done!
|
||||
+14
-14
@@ -858,7 +858,7 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name);
|
||||
}
|
||||
if (req->md_alg == NULL) {
|
||||
req->md_alg = req->digest = EVP_md5();
|
||||
req->md_alg = req->digest = EVP_sha1();
|
||||
}
|
||||
|
||||
PHP_SSL_CONFIG_SYNTAX_CHECK(extensions_section);
|
||||
@@ -4321,6 +4321,7 @@ PHP_FUNCTION(openssl_seal)
|
||||
|
||||
if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) {
|
||||
RETVAL_FALSE;
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
@@ -4331,10 +4332,12 @@ PHP_FUNCTION(openssl_seal)
|
||||
#endif
|
||||
/* allocate one byte extra to make room for \0 */
|
||||
buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx));
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) {
|
||||
RETVAL_FALSE;
|
||||
efree(buf);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
@@ -4367,6 +4370,7 @@ PHP_FUNCTION(openssl_seal)
|
||||
efree(buf);
|
||||
}
|
||||
RETVAL_LONG(len1 + len2);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
clean_exit:
|
||||
for (i=0; i<nkeys; i++) {
|
||||
@@ -4425,25 +4429,21 @@ PHP_FUNCTION(openssl_open)
|
||||
if (EVP_OpenInit(&ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) {
|
||||
if (!EVP_OpenFinal(&ctx, buf + len1, &len2) || (len1 + len2 == 0)) {
|
||||
efree(buf);
|
||||
if (keyresource == -1) {
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
zval_dtor(opendata);
|
||||
buf[len1 + len2] = '\0';
|
||||
ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0);
|
||||
RETVAL_TRUE;
|
||||
}
|
||||
} else {
|
||||
efree(buf);
|
||||
if (keyresource == -1) {
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
if (keyresource == -1) {
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
zval_dtor(opendata);
|
||||
buf[len1 + len2] = '\0';
|
||||
ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0);
|
||||
RETURN_TRUE;
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -5014,7 +5014,7 @@ PHP_FUNCTION(openssl_cipher_iv_length)
|
||||
|
||||
|
||||
/* {{{ proto string openssl_dh_compute_key(string pub_key, resource dh_key)
|
||||
Computes shared sicret for public value of remote DH key and local DH key */
|
||||
Computes shared secret for public value of remote DH key and local DH key */
|
||||
PHP_FUNCTION(openssl_dh_compute_key)
|
||||
{
|
||||
zval *key;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Firebird/InterBase driver for PDO
|
||||
Firebird driver for PDO
|
||||
Ard Biesheuvel
|
||||
@@ -1,7 +1,3 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(pdo-firebird,for Firebird support for PDO,
|
||||
[ --with-pdo-firebird[=DIR] PDO: Firebird support. DIR is the Firebird base
|
||||
install directory [/opt/firebird]])
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("pdo-firebird", "Firebird support for PDO", "no");
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -607,14 +605,14 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
|
||||
static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
|
||||
ISC_STATUS *s = H->isc_status;
|
||||
const ISC_STATUS *s = H->isc_status;
|
||||
char buf[400];
|
||||
long i = 0, l, sqlcode = isc_sqlcode(s);
|
||||
|
||||
if (sqlcode) {
|
||||
add_next_index_long(info, sqlcode);
|
||||
|
||||
while ((l = isc_interprete(&buf[i],&s))) {
|
||||
while ((sizeof(buf)>(i+2))&&(l = fb_interpret(&buf[i],(sizeof(buf)-i-2),&s))) {
|
||||
i += l;
|
||||
strcpy(&buf[i++], " ");
|
||||
}
|
||||
@@ -697,8 +695,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
|
||||
|
||||
if (!dbh->methods) {
|
||||
char errmsg[512];
|
||||
ISC_STATUS *s = H->isc_status;
|
||||
isc_interprete(errmsg, &s);
|
||||
const ISC_STATUS *s = H->isc_status;
|
||||
fb_interpret(errmsg, sizeof(errmsg),&s);
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), H->isc_status[1] TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
|
||||
"HY000", H->isc_status[1], errmsg);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -91,7 +89,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */
|
||||
PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "PDO Driver for Firebird/InterBase", "enabled");
|
||||
php_info_print_table_header(2, "PDO Driver for Firebird", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_PDO_FIREBIRD_H
|
||||
#define PHP_PDO_FIREBIRD_H
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_PDO_FIREBIRD_INT_H
|
||||
#define PHP_PDO_FIREBIRD_INT_H
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@ Basic test of POSIX getpgid(), kill(), get_last_error() and strerror() functions
|
||||
Kill pid=%d
|
||||
bool(false)
|
||||
int(%d)
|
||||
string(%d) %sNo such process%s
|
||||
string(%d) %s%rNo such process|Operation not permitted%r%s
|
||||
===DONE====
|
||||
|
||||
|
||||
+23
-14
@@ -50,6 +50,12 @@
|
||||
|
||||
#define FILE_PREFIX "sess_"
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# ifndef O_NOFOLLOW
|
||||
# define O_NOFOLLOW 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
char *lastkey;
|
||||
@@ -146,6 +152,7 @@ static void ps_files_close(ps_files *data)
|
||||
static void ps_files_open(ps_files *data, const char *key TSRMLS_DC)
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
struct stat sbuf;
|
||||
|
||||
if (data->fd < 0 || !data->lastkey || strcmp(key, data->lastkey)) {
|
||||
if (data->lastkey) {
|
||||
@@ -166,24 +173,26 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC)
|
||||
|
||||
data->lastkey = estrdup(key);
|
||||
|
||||
/* O_NOFOLLOW to prevent us from following evil symlinks */
|
||||
#ifdef O_NOFOLLOW
|
||||
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY | O_NOFOLLOW, data->filemode);
|
||||
#else
|
||||
/* Check to make sure that the opened file is not outside of allowable dirs.
|
||||
This is not 100% safe but it's hard to do something better without O_NOFOLLOW */
|
||||
if(PG(open_basedir) && lstat(buf, &sbuf) == 0 && S_ISLNK(sbuf.st_mode) && php_check_open_basedir(buf TSRMLS_CC)) {
|
||||
return;
|
||||
}
|
||||
data->fd = VCWD_OPEN_MODE(buf, O_CREAT | O_RDWR | O_BINARY, data->filemode);
|
||||
#endif
|
||||
|
||||
if (data->fd != -1) {
|
||||
#ifndef PHP_WIN32
|
||||
/* check to make sure that the opened file is not a symlink, linking to data outside of allowable dirs */
|
||||
if (PG(open_basedir)) {
|
||||
struct stat sbuf;
|
||||
|
||||
if (fstat(data->fd, &sbuf)) {
|
||||
close(data->fd);
|
||||
data->fd = -1;
|
||||
return;
|
||||
}
|
||||
if (S_ISLNK(sbuf.st_mode) && php_check_open_basedir(buf TSRMLS_CC)) {
|
||||
close(data->fd);
|
||||
data->fd = -1;
|
||||
return;
|
||||
}
|
||||
/* check that this session file was created by us or root – we
|
||||
don't want to end up accepting the sessions of another webapp */
|
||||
if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) {
|
||||
close(data->fd);
|
||||
data->fd = -1;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
flock(data->fd, LOCK_EX);
|
||||
|
||||
@@ -1129,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
|
||||
node = NULL;
|
||||
} else if (sxe->iter.type != SXE_ITER_CHILD) {
|
||||
|
||||
if ( !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
|
||||
if ( !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
|
||||
node = node->children;
|
||||
} else {
|
||||
iter_data = sxe->iter.data;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
--TEST--
|
||||
Bug #66084 simplexml_load_string() mangles empty node name, var_dump variant
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip simplexml not available"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo var_dump(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n";
|
||||
echo var_dump(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n";
|
||||
echo var_dump(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n";
|
||||
echo var_dump(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
object(SimpleXMLElement)#1 (2) {
|
||||
["b"]=>
|
||||
object(SimpleXMLElement)#2 (0) {
|
||||
}
|
||||
["c"]=>
|
||||
object(SimpleXMLElement)#3 (1) {
|
||||
["x"]=>
|
||||
object(SimpleXMLElement)#4 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object(SimpleXMLElement)#1 (3) {
|
||||
["b"]=>
|
||||
object(SimpleXMLElement)#3 (0) {
|
||||
}
|
||||
["d"]=>
|
||||
object(SimpleXMLElement)#2 (0) {
|
||||
}
|
||||
["c"]=>
|
||||
object(SimpleXMLElement)#4 (1) {
|
||||
["x"]=>
|
||||
object(SimpleXMLElement)#5 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object(SimpleXMLElement)#1 (2) {
|
||||
["b"]=>
|
||||
object(SimpleXMLElement)#4 (0) {
|
||||
}
|
||||
["c"]=>
|
||||
object(SimpleXMLElement)#2 (2) {
|
||||
["d"]=>
|
||||
object(SimpleXMLElement)#3 (0) {
|
||||
}
|
||||
["x"]=>
|
||||
object(SimpleXMLElement)#5 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object(SimpleXMLElement)#1 (2) {
|
||||
["b"]=>
|
||||
object(SimpleXMLElement)#2 (0) {
|
||||
}
|
||||
["c"]=>
|
||||
object(SimpleXMLElement)#4 (1) {
|
||||
["d"]=>
|
||||
object(SimpleXMLElement)#5 (1) {
|
||||
["x"]=>
|
||||
object(SimpleXMLElement)#3 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #66084 simplexml_load_string() mangles empty node name, json variant
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("simplexml")) print "skip simplexml not available"; ?>
|
||||
<?php if (!extension_loaded("json")) print "skip json not available"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n";
|
||||
echo json_encode(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n";
|
||||
echo json_encode(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n";
|
||||
echo json_encode(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
{"b":{},"c":{"x":{}}}
|
||||
{"b":{},"d":{},"c":{"x":{}}}
|
||||
{"b":{},"c":{"d":{},"x":{}}}
|
||||
{"b":{},"c":{"d":{"x":{}}}}
|
||||
@@ -1395,8 +1395,8 @@ static const entity_multicodepoint_row multi_cp_html5_02ACC[] = {
|
||||
{ {0x0FE00, "varsupsetneqq", 13} },
|
||||
};
|
||||
static const entity_multicodepoint_row multi_cp_html5_02AFD[] = {
|
||||
{ {01, NULL , 0} },
|
||||
{ {0x0FE00, "varsupsetneqq", 13} },
|
||||
{ {01, "parsl", 5} },
|
||||
{ {0x020E5, "nparsl", 6} },
|
||||
};
|
||||
|
||||
/* End of double code point tables }}} */
|
||||
|
||||
@@ -461,6 +461,7 @@ if (empty($multicp_rows))
|
||||
|
||||
ksort($multicp_rows);
|
||||
foreach ($multicp_rows as &$v) { ksort($v); }
|
||||
unset($v);
|
||||
|
||||
echo
|
||||
"/* {{{ Start of double code point tables for $name */", "\n\n";
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "php_image.h"
|
||||
#ifdef PHP_WIN32
|
||||
#include "win32/php_stdint.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
|
||||
#include "zlib.h"
|
||||
@@ -163,6 +166,7 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream TSRMLS_DC)
|
||||
result = (struct gfxinfo *) ecalloc (1, sizeof(struct gfxinfo));
|
||||
result->width = (((unsigned int)dim[ 7]) << 24) + (((unsigned int)dim[ 6]) << 16) + (((unsigned int)dim[ 5]) << 8) + ((unsigned int) dim[ 4]);
|
||||
result->height = (((unsigned int)dim[11]) << 24) + (((unsigned int)dim[10]) << 16) + (((unsigned int)dim[ 9]) << 8) + ((unsigned int) dim[ 8]);
|
||||
result->height = abs((int32_t)result->height);
|
||||
result->bits = (((unsigned int)dim[15]) << 8) + ((unsigned int)dim[14]);
|
||||
} else {
|
||||
return NULL;
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
|
||||
if (headers != NULL) {
|
||||
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers);
|
||||
} else {
|
||||
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n", php_getuid(TSRMLS_C), f);
|
||||
spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f);
|
||||
}
|
||||
efree(f);
|
||||
}
|
||||
|
||||
+31
-10
@@ -112,8 +112,17 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||
zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
|
||||
zend_hash_move_forward_ex(target_hash, &pos)) {
|
||||
|
||||
convert_to_string_ex(element);
|
||||
el_len = Z_STRLEN_PP(element);
|
||||
if (Z_TYPE_PP(element) != IS_STRING) {
|
||||
zval tmp;
|
||||
|
||||
MAKE_COPY_ZVAL(element, &tmp);
|
||||
convert_to_string(&tmp);
|
||||
el_len = Z_STRLEN(tmp);
|
||||
|
||||
zval_dtor(&tmp);
|
||||
} else {
|
||||
el_len = Z_STRLEN_PP(element);
|
||||
}
|
||||
if (el_len == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -125,7 +134,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||
if (string_length == 0) {
|
||||
continue;
|
||||
}
|
||||
sizeenv += string_length+1;
|
||||
sizeenv += string_length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -138,19 +147,26 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||
for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
|
||||
zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
|
||||
zend_hash_move_forward_ex(target_hash, &pos)) {
|
||||
zval tmp;
|
||||
|
||||
convert_to_string_ex(element);
|
||||
el_len = Z_STRLEN_PP(element);
|
||||
|
||||
if (el_len == 0) {
|
||||
continue;
|
||||
if (Z_TYPE_PP(element) != IS_STRING) {
|
||||
MAKE_COPY_ZVAL(element, &tmp);
|
||||
convert_to_string(&tmp);
|
||||
} else {
|
||||
tmp = **element;
|
||||
}
|
||||
|
||||
data = Z_STRVAL_PP(element);
|
||||
el_len = Z_STRLEN(tmp);
|
||||
|
||||
if (el_len == 0) {
|
||||
goto next_element;
|
||||
}
|
||||
|
||||
data = Z_STRVAL(tmp);
|
||||
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
if (string_length == 0) {
|
||||
continue;
|
||||
goto next_element;
|
||||
}
|
||||
|
||||
l = string_length + el_len + 1;
|
||||
@@ -175,6 +191,11 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||
case HASH_KEY_NON_EXISTANT:
|
||||
break;
|
||||
}
|
||||
|
||||
next_element:
|
||||
if (Z_TYPE_PP(element) != IS_STRING) {
|
||||
zval_dtor(&tmp);
|
||||
}
|
||||
}
|
||||
|
||||
assert((uint)(p - env.envp) <= sizeenv);
|
||||
|
||||
@@ -23,7 +23,22 @@ GetImageSize()
|
||||
var_dump($result);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(12) {
|
||||
array(13) {
|
||||
["test-1pix.bmp"]=>
|
||||
array(6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(1)
|
||||
[2]=>
|
||||
int(6)
|
||||
[3]=>
|
||||
string(20) "width="1" height="1""
|
||||
["bits"]=>
|
||||
int(24)
|
||||
["mime"]=>
|
||||
string(14) "image/x-ms-bmp"
|
||||
}
|
||||
["test1bpix.bmp"]=>
|
||||
array(6) {
|
||||
[0]=>
|
||||
|
||||
@@ -25,7 +25,9 @@ image_type_to_mime_type()
|
||||
var_dump($result);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(12) {
|
||||
array(13) {
|
||||
["test-1pix.bmp"]=>
|
||||
string(14) "image/x-ms-bmp"
|
||||
["test1bpix.bmp"]=>
|
||||
string(14) "image/x-ms-bmp"
|
||||
["test1pix.bmp"]=>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 58 B |
@@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Bug #66535: Extra newline if add_x_header and no additional headers are used
|
||||
--INI--
|
||||
sendmail_path=tee mailBasic.out >/dev/null
|
||||
mail.add_x_header = On
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(substr(PHP_OS, 0, 3) == "WIN")
|
||||
die("skip Won't run on Windows");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
|
||||
* Description: Send an email message
|
||||
* Source code: ext/standard/mail.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing mail() : send email without additional headers ***\n";
|
||||
|
||||
// Initialise all required variables
|
||||
$to = 'user@company.com';
|
||||
$subject = 'Test Subject';
|
||||
$message = 'A Message';
|
||||
|
||||
$outFile = "mailBasic.out";
|
||||
@unlink($outFile);
|
||||
|
||||
var_dump( mail($to, $subject, $message) );
|
||||
echo file_get_contents($outFile);
|
||||
unlink($outFile);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing mail() : send email without additional headers ***
|
||||
bool(true)
|
||||
To: user@company.com
|
||||
Subject: Test Subject
|
||||
X-PHP-Originating-Script: %d:bug66535.php
|
||||
|
||||
A Message
|
||||
===DONE===
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #64330 (stream_socket_server() creates wrong Abstract Namespace UNIX sockets)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!in_array("unix", stream_get_transports())) die("SKIP unix domain sockets unavailable");
|
||||
if (!stristr(PHP_OS, "Linux")) die('skip abstract namespace is a Linux-only feature');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test\n";
|
||||
$server = stream_socket_server("unix://\x00/MyBindName");
|
||||
$client = stream_socket_client("unix://\x00/MyBindName");
|
||||
if ($client) {
|
||||
echo "ok\n";
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Test
|
||||
ok
|
||||
===DONE===
|
||||
@@ -0,0 +1,57 @@
|
||||
--TEST--
|
||||
Bug #60602 proc_open() modifies environment if it contains arrays
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$descs = array(
|
||||
0 => array('pipe', 'r'), // stdin
|
||||
1 => array('pipe', 'w'), // stdout
|
||||
2 => array('pipe', 'w'), // strerr
|
||||
);
|
||||
|
||||
$environment = array('test' => array(1, 2, 3));
|
||||
|
||||
$cmd = (substr(PHP_OS, 0, 3) == 'WIN') ? 'dir' : 'ls';
|
||||
$p = proc_open($cmd, $descs, $pipes, '.', $environment);
|
||||
|
||||
if (is_resource($p)) {
|
||||
$data = '';
|
||||
|
||||
while (1) {
|
||||
$w = $e = NULL;
|
||||
$n = stream_select($pipes, $w, $e, 300);
|
||||
|
||||
if ($n === false) {
|
||||
echo "no streams \n";
|
||||
break;
|
||||
} else if ($n === 0) {
|
||||
echo "process timed out\n";
|
||||
proc_terminate($p, 9);
|
||||
break;
|
||||
} else if ($n > 0) {
|
||||
$line = fread($pipes[1], 8192);
|
||||
if (strlen($line) == 0) {
|
||||
/* EOF */
|
||||
break;
|
||||
}
|
||||
$data .= $line;
|
||||
}
|
||||
}
|
||||
var_dump(strlen($data));
|
||||
|
||||
$ret = proc_close($p);
|
||||
var_dump($ret);
|
||||
var_dump(is_array($environment['test']));
|
||||
} else {
|
||||
echo "no process\n";
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
int(%d)
|
||||
int(0)
|
||||
bool(true)
|
||||
==DONE==
|
||||
@@ -0,0 +1,78 @@
|
||||
--TEST--
|
||||
Bug #61019 (Out of memory on command stream_get_contents)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "Test\n";
|
||||
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
||||
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||
2 => array("pipe", "w") // stderr is a pipe that the child will write to
|
||||
);
|
||||
|
||||
$process=proc_open("echo testtext",$descriptorspec,$pipes);
|
||||
if(is_resource($process))
|
||||
{
|
||||
stream_set_blocking($pipes[0],false);
|
||||
stream_set_blocking($pipes[1],false);
|
||||
stream_set_blocking($pipes[2],false);
|
||||
stream_set_write_buffer($pipes[0],0);
|
||||
stream_set_read_buffer($pipes[1],0);
|
||||
stream_set_read_buffer($pipes[2],0);
|
||||
$stdin_stream="";
|
||||
$stderr_stream="";
|
||||
|
||||
echo "External command executed\n";
|
||||
do
|
||||
{
|
||||
$process_state=proc_get_status($process);
|
||||
$tmp_stdin=stream_get_contents($pipes[1]);
|
||||
if($tmp_stdin)
|
||||
{
|
||||
$stdin_stream=$stdin_stream.$tmp_stdin;
|
||||
}
|
||||
$tmp_stderr=stream_get_contents($pipes[2]);
|
||||
if($tmp_stderr)
|
||||
{
|
||||
$stderr_stream=$stderr_stream.$tmp_stderr;
|
||||
}
|
||||
} while($process_state['running']);
|
||||
|
||||
echo "External command exit: ".$process_state['exitcode']."\n";
|
||||
|
||||
//read outstanding data
|
||||
$tmp_stdin=stream_get_contents($pipes[1]);
|
||||
if($tmp_stdin)
|
||||
{
|
||||
$stdin_stream=$stdin_stream.$tmp_stdin;
|
||||
}
|
||||
$tmp_stderr=stream_get_contents($pipes[2]);
|
||||
if($tmp_stderr)
|
||||
{
|
||||
$stderr_stream=$stderr_stream.$tmp_stderr;
|
||||
}
|
||||
|
||||
fclose ($pipes[0]);
|
||||
fclose ($pipes[1]);
|
||||
fclose ($pipes[2]);
|
||||
|
||||
proc_close($process);
|
||||
|
||||
echo "STDOUT: ".$stdin_stream."\n";
|
||||
echo "STDERR: ".$stderr_stream."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Can't start external command\n";
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Test
|
||||
External command executed
|
||||
External command exit: 0
|
||||
STDOUT: testtext
|
||||
|
||||
STDERR:
|
||||
===DONE===
|
||||
@@ -46,7 +46,7 @@ echo "Done\n";
|
||||
--EXPECT--
|
||||
*** Testing get_html_translation_table() : basic functionality/HTML 5 ***
|
||||
-- with table = HTML_ENTITIES, ENT_COMPAT --
|
||||
int(1509)
|
||||
int(1510)
|
||||
Array
|
||||
(
|
||||
[Æ] => Æ
|
||||
@@ -1108,6 +1108,7 @@ Array
|
||||
[⋾] => ⋾
|
||||
[⋽] => ⋽
|
||||
[∦] => ∦
|
||||
[⫽⃥] => &nparsl
|
||||
[∂̸] => &npart
|
||||
[⨔] => ⨔
|
||||
[⊀] => ⊀
|
||||
@@ -1196,6 +1197,7 @@ Array
|
||||
[⌽] => ⌽
|
||||
[¶] => ¶
|
||||
[⫳] => ⫳
|
||||
[⫽] => ⫽
|
||||
[∂] => ∂
|
||||
[п] => п
|
||||
[%] => %
|
||||
@@ -1500,7 +1502,6 @@ Array
|
||||
[⦜] => ⦜
|
||||
[ϰ] => ϰ
|
||||
[⫌︀] => &varsupsetneqq
|
||||
[⫽︀] => &varsupsetneqq
|
||||
[⊲] => ⊲
|
||||
[в] => в
|
||||
[⊢] => ⊢
|
||||
@@ -1561,9 +1562,9 @@ Array
|
||||
[] => ‌
|
||||
)
|
||||
-- with table = HTML_ENTITIES, ENT_QUOTES --
|
||||
int(1510)
|
||||
int(1511)
|
||||
-- with table = HTML_ENTITIES, ENT_NOQUOTES --
|
||||
int(1508)
|
||||
int(1509)
|
||||
-- with table = HTML_SPECIALCHARS, ENT_COMPAT --
|
||||
int(4)
|
||||
Array
|
||||
|
||||
@@ -1418,6 +1418,7 @@ foreach ($mpcent as $i) {
|
||||
⫱ U+02AF1
|
||||
⫲ U+02AF2
|
||||
⫳ U+02AF3
|
||||
⫽ U+02AFD
|
||||
ff U+0FB00
|
||||
fi U+0FB01
|
||||
fl U+0FB02
|
||||
@@ -1620,4 +1621,4 @@ foreach ($mpcent as $i) {
|
||||
⫆̸ U+02AC6 U+00338
|
||||
⫋︀ U+02ACB U+0FE00
|
||||
⫌︀ U+02ACC U+0FE00
|
||||
⫌︀ U+02AFD U+0FE00
|
||||
⫽︀ U+02AFD U+0FE00
|
||||
+2
-2
@@ -266,8 +266,8 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
|
||||
p = s;
|
||||
} else {
|
||||
/* memrchr is a GNU specific extension
|
||||
Emulate for wide compatibility */
|
||||
for(p = e; *p != ':' && p >= s; p--);
|
||||
Emulate for wide compatability */
|
||||
for(p = e; p >= s && *p != ':'; p--);
|
||||
}
|
||||
|
||||
if (p >= s && *p == ':') {
|
||||
|
||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user