From: Rasmus Lerdorf Date: Sun, 26 Jul 2009 08:38:01 +0000 (+0000) Subject: Internally-created array indices are unicode - fix tests to match X-Git-Tag: php-5.4.0alpha1~191^2~2960 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3ae25ee66d5ee0998abd28985aa7937c89dc181;p=php Internally-created array indices are unicode - fix tests to match --- diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 26eeaad10f..23a8cb2400 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -660,13 +660,13 @@ PHP_FUNCTION(posix_uname) array_init(return_value); - add_assoc_string(return_value, "sysname", u.sysname, 1); - add_assoc_string(return_value, "nodename", u.nodename, 1); - add_assoc_string(return_value, "release", u.release, 1); - add_assoc_string(return_value, "version", u.version, 1); - add_assoc_string(return_value, "machine", u.machine, 1); + add_ascii_assoc_string(return_value, "sysname", u.sysname, 1); + add_ascii_assoc_string(return_value, "nodename", u.nodename, 1); + add_ascii_assoc_string(return_value, "release", u.release, 1); + add_ascii_assoc_string(return_value, "version", u.version, 1); + add_ascii_assoc_string(return_value, "machine", u.machine, 1); #if defined(_GNU_SOURCE) && !defined(DARWIN) && defined(HAVE_UTSNAME_DOMAINNAME) - add_assoc_string(return_value, "domainname", u.domainname, 1); + add_ascii_assoc_string(return_value, "domainname", u.domainname, 1); #endif } /* }}} */ @@ -691,11 +691,11 @@ PHP_FUNCTION(posix_times) array_init(return_value); - add_assoc_long(return_value, "ticks", ticks); /* clock ticks */ - add_assoc_long(return_value, "utime", t.tms_utime); /* user time */ - add_assoc_long(return_value, "stime", t.tms_stime); /* system time */ - add_assoc_long(return_value, "cutime", t.tms_cutime); /* user time of children */ - add_assoc_long(return_value, "cstime", t.tms_cstime); /* system time of children */ + add_ascii_assoc_long(return_value, "ticks", ticks); /* clock ticks */ + add_ascii_assoc_long(return_value, "utime", t.tms_utime); /* user time */ + add_ascii_assoc_long(return_value, "stime", t.tms_stime); /* system time */ + add_ascii_assoc_long(return_value, "cutime", t.tms_cutime); /* user time of children */ + add_ascii_assoc_long(return_value, "cstime", t.tms_cstime); /* system time of children */ } /* }}} */ @@ -953,13 +953,13 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */ MAKE_STD_ZVAL(array_members); array_init(array_members); - add_assoc_string(array_group, "name", g->gr_name, 1); - add_assoc_string(array_group, "passwd", g->gr_passwd, 1); + add_ascii_assoc_string(array_group, "name", g->gr_name, 1); + add_ascii_assoc_string(array_group, "passwd", g->gr_passwd, 1); for (count=0; g->gr_mem[count] != NULL; count++) { add_next_index_string(array_members, g->gr_mem[count], 1); } - zend_hash_update(Z_ARRVAL_P(array_group), "members", sizeof("members"), (void*)&array_members, sizeof(zval*), NULL); - add_assoc_long(array_group, "gid", g->gr_gid); + zend_ascii_hash_update(Z_ARRVAL_P(array_group), "members", sizeof("members"), (void*)&array_members, sizeof(zval*), NULL); + add_ascii_assoc_long(array_group, "gid", g->gr_gid); return 1; } /* }}} */ @@ -1122,13 +1122,13 @@ int php_posix_passwd_to_array(struct passwd *pw, zval *return_value) /* {{{ */ if (NULL == return_value || Z_TYPE_P(return_value) != IS_ARRAY) return 0; - add_assoc_string(return_value, "name", pw->pw_name, 1); - add_assoc_string(return_value, "passwd", pw->pw_passwd, 1); - add_assoc_long (return_value, "uid", pw->pw_uid); - add_assoc_long (return_value, "gid", pw->pw_gid); - add_assoc_string(return_value, "gecos", pw->pw_gecos, 1); - add_assoc_string(return_value, "dir", pw->pw_dir, 1); - add_assoc_string(return_value, "shell", pw->pw_shell, 1); + add_ascii_assoc_string(return_value, "name", pw->pw_name, 1); + add_ascii_assoc_string(return_value, "passwd", pw->pw_passwd, 1); + add_ascii_assoc_long (return_value, "uid", pw->pw_uid); + add_ascii_assoc_long (return_value, "gid", pw->pw_gid); + add_ascii_assoc_string(return_value, "gecos", pw->pw_gecos, 1); + add_ascii_assoc_string(return_value, "dir", pw->pw_dir, 1); + add_ascii_assoc_string(return_value, "shell", pw->pw_shell, 1); return 1; } /* }}} */ @@ -1256,15 +1256,15 @@ static int posix_addlimit(int limit, char *name, zval *return_value TSRMLS_DC) } if (rl.rlim_cur == RLIM_INFINITY) { - add_assoc_stringl(return_value, soft, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); + add_ascii_assoc_stringl(return_value, soft, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); } else { - add_assoc_long(return_value, soft, rl.rlim_cur); + add_ascii_assoc_long(return_value, soft, rl.rlim_cur); } if (rl.rlim_max == RLIM_INFINITY) { - add_assoc_stringl(return_value, hard, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); + add_ascii_assoc_stringl(return_value, hard, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); } else { - add_assoc_long(return_value, hard, rl.rlim_max); + add_ascii_assoc_long(return_value, hard, rl.rlim_max); } return SUCCESS; diff --git a/ext/posix/tests/posix_getgrgid.phpt b/ext/posix/tests/posix_getgrgid.phpt index 139c9bdec3..0209d09732 100644 --- a/ext/posix/tests/posix_getgrgid.phpt +++ b/ext/posix/tests/posix_getgrgid.phpt @@ -12,19 +12,19 @@ if (!extension_loaded('posix')) { --FILE-- 0) { - foreach ($grp[b'members'] as $idx => $username) { + if (count($grp['members']) > 0) { + foreach ($grp['members'] as $idx => $username) { if (!is_int($idx)) { die('Index in members Array is not an int.'); } @@ -34,10 +34,10 @@ if (!isset($grp[b'members'])) { } } } -if (!isset($grp[b'gid'])) { +if (!isset($grp['gid'])) { die('Array index "gid" does not exist.'); } -var_dump($grp[b'gid']); +var_dump($grp['gid']); ?> ===DONE=== --EXPECT-- diff --git a/ext/posix/tests/posix_times.phpt b/ext/posix/tests/posix_times.phpt index 6ad3407ccb..f57363ea0b 100644 --- a/ext/posix/tests/posix_times.phpt +++ b/ext/posix/tests/posix_times.phpt @@ -19,15 +19,15 @@ PHP Testfest Berlin 2009-05-10 ===DONE=== --EXPECTF-- array(5) { - ["ticks"]=> + [u"ticks"]=> int(%i) - ["utime"]=> + [u"utime"]=> int(%d) - ["stime"]=> + [u"stime"]=> int(%d) - ["cutime"]=> + [u"cutime"]=> int(%d) - ["cstime"]=> + [u"cstime"]=> int(%d) } ===DONE=== diff --git a/ext/posix/tests/posix_times_basic.phpt b/ext/posix/tests/posix_times_basic.phpt index eb8af10df4..b761b36a19 100644 --- a/ext/posix/tests/posix_times_basic.phpt +++ b/ext/posix/tests/posix_times_basic.phpt @@ -23,15 +23,15 @@ Test posix_times() function : basic functionality --EXPECTF-- Basic test of POSIX times function array(5) { - ["ticks"]=> + [u"ticks"]=> int(%d) - ["utime"]=> + [u"utime"]=> int(%d) - ["stime"]=> + [u"stime"]=> int(%d) - ["cutime"]=> + [u"cutime"]=> int(%d) - ["cstime"]=> + [u"cstime"]=> int(%d) } ===DONE==== diff --git a/ext/posix/tests/posix_uname.phpt b/ext/posix/tests/posix_uname.phpt index 12c4baec16..14bf89104f 100644 --- a/ext/posix/tests/posix_uname.phpt +++ b/ext/posix/tests/posix_uname.phpt @@ -19,15 +19,15 @@ PHP Testfest Berlin 2009-05-10 ===DONE=== --EXPECTF-- array(5) { - ["sysname"]=> + [u"sysname"]=> string(%d) "%s" - ["nodename"]=> + [u"nodename"]=> string(%d) "%s" - ["release"]=> + [u"release"]=> string(%d) "%s" - ["version"]=> + [u"version"]=> string(%d) "%s" - ["machine"]=> + [u"machine"]=> string(%d) "%s" } ===DONE===