Unicode support

This commit is contained in:
Dmitry Stogov 2005-08-16 15:09:51 +00:00
parent 903406ef8f
commit d0944d74f4
50 changed files with 1306 additions and 42 deletions

View File

@ -36,3 +36,15 @@ array(4) {
string(4) "tiro"
}
string(30) "Cessante causa cessat effectus"
--UEXPECTF--
array(4) {
[0]=>
unicode(5) "bonus"
[1]=>
unicode(3) "vir"
[2]=>
unicode(6) "semper"
[3]=>
unicode(4) "tiro"
}
unicode(30) "Cessante causa cessat effectus"

View File

@ -280,6 +280,7 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
case IS_BOOL:
case IS_DOUBLE:
case IS_NULL:
case IS_UNICODE:
if (value->refcount > 1) {
value_copy = *value;
zval_copy_ctor(&value_copy);
@ -288,6 +289,7 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
convert_to_string(value);
/* break missing intentionally */
case IS_STRING:
case IS_BINARY:
xmlNodeSetContentLen(node, Z_STRVAL_P(value), Z_STRLEN_P(value));
if (value == &value_copy) {
zval_dtor(value);
@ -427,8 +429,10 @@ next_iter:
case IS_BOOL:
case IS_DOUBLE:
case IS_NULL:
case IS_UNICODE:
convert_to_string(value);
case IS_STRING:
case IS_BINARY:
newnode = (xmlNodePtr)xmlNewProp(node, name, Z_STRVAL_P(value));
break;
default:
@ -511,8 +515,10 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node);
}
else {
zval tmp_zv;
if (Z_TYPE_P(member) != IS_STRING) {
zval tmp_zv = *member;
tmp_zv = *member;
zval_copy_ctor(&tmp_zv);
member = &tmp_zv;
convert_to_string(member);
@ -526,7 +532,10 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
}
node = nnext;
}
}
if (member == &tmp_zv) {
zval_dtor(&tmp_zv);
}
}
if (node) {
exists = 1;
}
@ -681,7 +690,7 @@ sxe_properties_get(zval *object TSRMLS_DC)
rv = sxe->properties;
} else {
ALLOC_HASHTABLE(rv);
zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_u_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0, UG(unicode));
sxe->properties = rv;
}
@ -698,6 +707,9 @@ sxe_properties_get(zval *object TSRMLS_DC)
if (node->type == XML_TEXT_NODE) {
MAKE_STD_ZVAL(value);
ZVAL_STRING(value, xmlNodeListGetString(node->doc, node, 1), 1);
if (UG(unicode)) {
convert_to_unicode(value);
}
zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL);
goto next_iter;
}
@ -999,6 +1011,12 @@ cast_object(zval *object, int type, char *contents TSRMLS_DC)
case IS_STRING:
convert_to_string(object);
break;
case IS_BINARY:
convert_to_binary(object);
break;
case IS_UNICODE:
convert_to_unicode(object);
break;
case IS_BOOL:
convert_to_boolean(object);
break;
@ -1506,11 +1524,20 @@ static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_k
curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->node)->node;
}
namelen = xmlStrlen(curnode->name);
*str_key = estrndup(curnode->name, namelen);
*str_key_len = namelen + 1;
return HASH_KEY_IS_STRING;
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
int32_t u_len;
namelen = xmlStrlen(curnode->name);
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), (UChar**)str_key, &u_len, (char*)curnode->name, namelen, &status);
*str_key_len = u_len + 1;
return HASH_KEY_IS_UNICODE;
} else {
namelen = xmlStrlen(curnode->name);
*str_key = estrndup(curnode->name, namelen);
*str_key_len = namelen + 1;
return HASH_KEY_IS_STRING;
}
}
ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC)

View File

@ -37,3 +37,13 @@ array(1) {
}
}
bool(false)
--UEXPECTF--
array(1) {
[0]=>
object(SimpleXMLElement)#%d (1) {
[u"test"]=>
object(SimpleXMLElement)#%d (0) {
}
}
}
bool(false)

View File

@ -31,7 +31,7 @@ EOF
foreach($sxe->children() as $name=>$val) {
var_dump($name);
var_dump(get_class($val));
var_dump(trim((string)$val));
var_dump(trim($val));
}
?>
===DONE===

View File

@ -54,3 +54,21 @@ object(SimpleXMLElement)#%d (1) {
string(3) "Boe"
}
===DONE===
--UEXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(3) "Joe"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(3) "Joe"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(3) "Joe"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(3) "Boe"
}
===DONE===

View File

@ -28,3 +28,11 @@ object(SimpleXMLElement)#%d (1) {
string(11) "slide_*.xml"
}
===DONE===
--UEXPECTF--
object(SimpleXMLElement)#%d (0) {
}
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(11) "slide_*.xml"
}
===DONE===

View File

@ -80,7 +80,16 @@ SPL_METHOD(SimpleXMLIterator, key) /* {{{ */
intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC);
if (intern != NULL && intern->node != NULL) {
curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->node)->node;
RETURN_STRINGL((char*)curnode->name, xmlStrlen(curnode->name), 1);
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, (char*)curnode->name, xmlStrlen(curnode->name), &status);
RETURN_UNICODEL(u_str, u_len, 0);
} else {
RETURN_STRINGL((char*)curnode->name, xmlStrlen(curnode->name), 1);
}
}
RETURN_FALSE;

View File

@ -75,3 +75,26 @@ string(7) "Foo Bar"
string(17) "SimpleXMLIterator"
string(10) "Bla bla 1."
===DONE===
--UEXPECT--
unicode(5) "elem1"
unicode(17) "SimpleXMLIterator"
unicode(10) "Bla bla 1."
unicode(5) "elem2"
unicode(17) "SimpleXMLIterator"
unicode(28) "Here we have some text data."
unicode(5) "elem3"
unicode(17) "SimpleXMLIterator"
unicode(19) "And here some more."
unicode(5) "elem4"
unicode(17) "SimpleXMLIterator"
unicode(15) "Wow once again."
unicode(6) "elem11"
unicode(17) "SimpleXMLIterator"
unicode(10) "Bla bla 2."
unicode(7) "elem111"
unicode(17) "SimpleXMLIterator"
unicode(7) "Foo Bar"
===DUMP===
unicode(17) "SimpleXMLIterator"
unicode(10) "Bla bla 1."
===DONE===

View File

@ -77,3 +77,20 @@ string(7) "elem111"
string(17) "SimpleXMLIterator"
string(7) "Foo Bar"
===DONE===
--UEXPECTF--
Warning: Invalid argument supplied for foreach() in %ssxe_003.php on line %d
===RESET===
bool(true)
unicode(5) "elem1"
unicode(10) "Bla bla 1."
unicode(5) "elem2"
unicode(17) "SimpleXMLIterator"
unicode(28) "Here we have some text data."
bool(true)
unicode(6) "elem11"
unicode(10) "Bla bla 2."
unicode(7) "elem111"
unicode(17) "SimpleXMLIterator"
unicode(7) "Foo Bar"
===DONE===

View File

@ -145,3 +145,62 @@ SXETest::next
SXETest::valid
SXETest::valid
===DONE===
--UEXPECTF--
SXETest::rewind
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(10) "Bla bla 1."
SXETest::getChildren
SXETest::rewind
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(28) "Here we have some text data."
SXETest::getChildren
SXETest::rewind
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(19) "And here some more."
SXETest::getChildren
SXETest::rewind
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(15) "Wow once again."
SXETest::next
SXETest::valid
SXETest::next
SXETest::valid
SXETest::next
SXETest::valid
SXETest::next
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(10) "Bla bla 2."
SXETest::getChildren
SXETest::rewind
SXETest::valid
SXETest::hasChildren
SXETest::valid
SXETest::current
unicode(7) "SXETest"
unicode(7) "Foo Bar"
SXETest::next
SXETest::valid
SXETest::next
SXETest::valid
SXETest::valid
===DONE===

View File

@ -876,12 +876,12 @@ static zend_object_value sqlite_object_new_exception(zend_class_entry *class_typ
static zend_class_entry *sqlite_get_ce_query(zval *object TSRMLS_DC)
{
return sqlite_ce_query;
return U_CLASS_ENTRY(sqlite_ce_query);
}
static zend_class_entry *sqlite_get_ce_ub_query(zval *object TSRMLS_DC)
{
return sqlite_ce_ub_query;
return U_CLASS_ENTRY(sqlite_ce_ub_query);
}
static zval * sqlite_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
@ -1183,7 +1183,7 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per
if (object) {
/* if object is not an object then we're called from the factory() function */
if (Z_TYPE_P(object) != IS_OBJECT) {
sqlite_instanciate(sqlite_ce_db, object TSRMLS_CC);
sqlite_instanciate(U_CLASS_ENTRY(sqlite_ce_db), object TSRMLS_CC);
}
/* and now register the object */
SQLITE_REGISTER_OBJECT(db, object, db)
@ -1290,7 +1290,7 @@ PHP_FUNCTION(sqlite_open)
zval *errmsg = NULL;
zval *object = getThis();
php_set_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception TSRMLS_CC);
php_set_error_handling(object ? EH_THROW : EH_NORMAL, U_CLASS_ENTRY(sqlite_ce_exception) TSRMLS_CC);
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
&filename, &filename_len, &mode, &errmsg)) {
php_std_error_handling();
@ -1345,7 +1345,7 @@ PHP_FUNCTION(sqlite_factory)
int filename_len;
zval *errmsg = NULL;
php_set_error_handling(EH_THROW, sqlite_ce_exception TSRMLS_CC);
php_set_error_handling(EH_THROW, U_CLASS_ENTRY(sqlite_ce_exception) TSRMLS_CC);
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
&filename, &filename_len, &mode, &errmsg)) {
php_std_error_handling();
@ -1570,9 +1570,9 @@ terminate:
if (object) {
sqlite_object *obj;
if (buffered) {
sqlite_instanciate(sqlite_ce_query, return_value TSRMLS_CC);
sqlite_instanciate(U_CLASS_ENTRY(sqlite_ce_query), return_value TSRMLS_CC);
} else {
sqlite_instanciate(sqlite_ce_ub_query, return_value TSRMLS_CC);
sqlite_instanciate(U_CLASS_ENTRY(sqlite_ce_ub_query), return_value TSRMLS_CC);
}
obj = (sqlite_object *) zend_object_store_get_object(return_value TSRMLS_CC);
obj->type = is_result;
@ -1685,11 +1685,27 @@ PHP_FUNCTION(sqlite_fetch_column_types)
php_sqlite_strtolower(colname);
}
if (result_type == PHPSQLITE_ASSOC) {
add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
}
if (result_type == PHPSQLITE_NUM) {
add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
if (UG(unicode)) {
char *tmp = colnames[ncols + i] ? (char *)colnames[ncols + i] : "";
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, tmp, strlen(tmp), &status);
if (result_type == PHPSQLITE_ASSOC) {
add_assoc_unicode(return_value, colname, u_str, 1);
}
if (result_type == PHPSQLITE_NUM) {
add_index_unicode(return_value, i, u_str, 1);
}
efree(u_str);
} else {
if (result_type == PHPSQLITE_ASSOC) {
add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
}
if (result_type == PHPSQLITE_NUM) {
add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
}
}
}
@ -1811,13 +1827,25 @@ static void php_sqlite_fetch_array(struct php_sqlite_result *res, int mode, zend
Z_STRVAL_P(decoded) = emalloc(strlen(rowdata[j]));
Z_STRLEN_P(decoded) = php_sqlite_decode_binary(rowdata[j]+1, Z_STRVAL_P(decoded));
Z_STRVAL_P(decoded)[Z_STRLEN_P(decoded)] = '\0';
Z_TYPE_P(decoded) = IS_STRING;
Z_TYPE_P(decoded) = UG(unicode)?IS_BINARY:IS_STRING;
if (!buffered) {
efree((char*)rowdata[j]);
rowdata[j] = NULL;
}
} else {
ZVAL_STRING(decoded, (char*)rowdata[j], buffered);
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, (char*)rowdata[j], strlen((char*)rowdata[j]), &status);
ZVAL_UNICODEL(decoded, u_str, u_len, 0);
if (!buffered) {
efree(rowdata[j]);
}
} else {
ZVAL_STRING(decoded, (char*)rowdata[j], buffered);
}
if (!buffered) {
rowdata[j] = NULL;
}
@ -1888,11 +1916,26 @@ static void php_sqlite_fetch_column(struct php_sqlite_result *res, zval *which,
char *decoded = emalloc(l);
l = php_sqlite_decode_binary(rowdata[j]+1, decoded);
decoded[l] = '\0';
RETVAL_STRINGL(decoded, l, 0);
if (UG(unicode)) {
RETVAL_BINARYL(decoded, l, 0);
} else {
RETVAL_STRINGL(decoded, l, 0);
}
if (!res->buffered) {
efree((char*)rowdata[j]);
rowdata[j] = NULL;
}
} else if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, (char*)rowdata[j], strlen((char*)rowdata[j]), &status);
RETVAL_UNICODEL(u_str, u_len, 0);
if (!res->buffered) {
efree(rowdata[j]);
rowdata[j] = NULL;
}
} else {
RETVAL_STRING((char*)rowdata[j], res->buffered);
if (!res->buffered) {
@ -1997,34 +2040,35 @@ PHP_FUNCTION(sqlite_fetch_object)
zend_fcall_info_cache fcc;
zval *retval_ptr;
zval *ctor_params = NULL;
zend_uchar class_name_type;
php_set_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception TSRMLS_CC);
php_set_error_handling(object ? EH_THROW : EH_NORMAL, U_CLASS_ENTRY(sqlite_ce_exception) TSRMLS_CC);
if (object) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|szb", &class_name, &class_name_len, &ctor_params, &decode_binary)) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|tzb", &class_name, &class_name_len, &class_name_type, &ctor_params, &decode_binary)) {
php_std_error_handling();
return;
}
RES_FROM_OBJECT(res, object);
if (!ZEND_NUM_ARGS()) {
ce = zend_standard_class_def;
ce = U_CLASS_ENTRY(zend_standard_class_def);
} else {
ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
ce = zend_u_fetch_class(class_name_type, class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
}
} else {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|szb", &zres, &class_name, &class_name_len, &ctor_params, &decode_binary)) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|tzb", &zres, &class_name, &class_name_len, &class_name_type, &ctor_params, &decode_binary)) {
php_std_error_handling();
return;
}
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
if (ZEND_NUM_ARGS() < 2) {
ce = zend_standard_class_def;
ce = U_CLASS_ENTRY(zend_standard_class_def);
} else {
ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
ce = zend_u_fetch_class(class_name_type, class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
}
}
if (!ce) {
zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Could not find class '%s'", class_name);
zend_throw_exception_ex(U_CLASS_ENTRY(sqlite_ce_exception), 0 TSRMLS_CC, "Could not find class '%s'", class_name);
php_std_error_handling();
return;
}
@ -2067,7 +2111,7 @@ PHP_FUNCTION(sqlite_fetch_object)
* single value is an array. Also we'd have to make that one
* argument passed by reference.
*/
zend_throw_exception(sqlite_ce_exception, "Parameter ctor_params must be an array", 0 TSRMLS_CC);
zend_throw_exception(U_CLASS_ENTRY(sqlite_ce_exception), "Parameter ctor_params must be an array", 0 TSRMLS_CC);
return;
}
} else {
@ -2082,7 +2126,7 @@ PHP_FUNCTION(sqlite_fetch_object)
fcc.object_pp = &return_value;
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Could not execute %s::%v()", class_name, ce->constructor->common.function_name);
zend_throw_exception_ex(U_CLASS_ENTRY(sqlite_ce_exception), 0 TSRMLS_CC, "Could not execute %s::%v()", class_name, ce->constructor->common.function_name);
} else {
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
@ -2092,7 +2136,7 @@ PHP_FUNCTION(sqlite_fetch_object)
efree(fci.params);
}
} else if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Class %s does not have a constructor, use NULL for parameter ctor_params or omit it", class_name);
zend_throw_exception_ex(U_CLASS_ENTRY(sqlite_ce_exception), 0 TSRMLS_CC, "Class %s does not have a constructor, use NULL for parameter ctor_params or omit it", class_name);
}
}
/* }}} */
@ -2164,6 +2208,7 @@ static void php_sqlite_fetch_single(struct php_sqlite_result *res, zend_bool dec
const char **rowdata;
char *decoded;
int decoded_len;
int free_decoded = 0;
/* check range of the row */
if (res->curr_row >= res->nrows) {
@ -2184,13 +2229,19 @@ static void php_sqlite_fetch_single(struct php_sqlite_result *res, zend_bool dec
efree((char*)rowdata[0]);
rowdata[0] = NULL;
}
free_decoded = 1;
} else if (rowdata[0]) {
decoded_len = strlen((char*)rowdata[0]);
if (res->buffered) {
decoded = estrndup((char*)rowdata[0], decoded_len);
if (UG(unicode)) {
decoded = (char*)rowdata[0];
} else {
decoded = estrndup((char*)rowdata[0], decoded_len);
}
} else {
decoded = (char*)rowdata[0];
rowdata[0] = NULL;
free_decoded = 1;
}
} else {
decoded = NULL;
@ -2206,6 +2257,16 @@ static void php_sqlite_fetch_single(struct php_sqlite_result *res, zend_bool dec
if (decoded == NULL) {
RETURN_NULL();
} else if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, decoded, decoded_len, &status);
if (free_decoded) {
efree(decoded);
}
RETURN_UNICODEL(u_str, u_len, 0);
} else {
RETURN_STRINGL(decoded, decoded_len, 0);
}
@ -2382,7 +2443,13 @@ PHP_FUNCTION(sqlite_libversion)
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
RETURN_STRING((char*)sqlite_libversion(), 1);
if (UG(unicode)) {
char *temp = (char*)sqlite_libversion();
UChar *u_temp = zend_ascii_to_unicode(temp, strlen(temp)+1 ZEND_FILE_LINE_CC);
RETURN_UNICODE(u_temp, 0);
} else {
RETURN_STRING((char*)sqlite_libversion(), 1);
}
}
/* }}} */
@ -2393,7 +2460,13 @@ PHP_FUNCTION(sqlite_libencoding)
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
RETURN_STRING((char*)sqlite_libencoding(), 1);
if (UG(unicode)) {
char *temp = (char*)sqlite_libencoding();
UChar *u_temp = zend_ascii_to_unicode(temp, strlen(temp)+1 ZEND_FILE_LINE_CC);
RETURN_UNICODE(u_temp, 0);
} else {
RETURN_STRING((char*)sqlite_libencoding(), 1);
}
}
/* }}} */
@ -2453,7 +2526,7 @@ static int sqlite_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
* count = obj->u.res->nrows;
return SUCCESS;
} else {
zend_throw_exception(sqlite_ce_exception, "Row count is not available for unbuffered queries", 0 TSRMLS_CC);
zend_throw_exception(U_CLASS_ENTRY(sqlite_ce_exception), "Row count is not available for unbuffered queries", 0 TSRMLS_CC);
return FAILURE;
}
} /* }}} */
@ -2590,7 +2663,16 @@ PHP_FUNCTION(sqlite_field_name)
RETURN_FALSE;
}
RETURN_STRING(res->col_names[field], 1);
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, res->col_names[field], strlen(res->col_names[field]), &status);
RETURN_UNICODEL(u_str, u_len, 0);
} else {
RETURN_STRING(res->col_names[field], 1);
}
}
/* }}} */
@ -2831,7 +2913,16 @@ PHP_FUNCTION(sqlite_error_string)
msg = sqlite_error_string(code);
if (msg) {
RETURN_STRING((char*)msg, 1);
if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
int32_t u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, msg, strlen(msg), &status);
RETURN_UNICODEL(u_str, u_len, 0);
} else {
RETURN_STRING((char*)msg, 1);
}
} else {
RETURN_NULL();
}

View File

@ -30,3 +30,18 @@ array(6) {
["c3"]=>
NULL
}
--UEXPECT--
array(6) {
[0]=>
unicode(10) "2002-01-02"
[u"c1"]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[u"c2"]=>
unicode(8) "12:49:00"
[2]=>
NULL
[u"c3"]=>
NULL
}

View File

@ -50,3 +50,34 @@ array(3) {
["c3"]=>
NULL
}
--UEXPECT--
array(6) {
[0]=>
unicode(10) "2002-01-02"
[u"c1"]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[u"c2"]=>
unicode(8) "12:49:00"
[2]=>
NULL
[u"c3"]=>
NULL
}
array(3) {
[0]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[2]=>
NULL
}
array(3) {
[u"c1"]=>
unicode(10) "2002-01-02"
[u"c2"]=>
unicode(8) "12:49:00"
[u"c3"]=>
NULL
}

View File

@ -48,3 +48,9 @@ array(1) {
string(11) "onetwothree"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(11) "onetwothree"
}
DONE!

View File

@ -53,3 +53,17 @@ array(1) {
string(10) "three-tres"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(7) "one-uno"
}
array(1) {
[0]=>
unicode(7) "two-dos"
}
array(1) {
[0]=>
unicode(10) "three-tres"
}
DONE!

View File

@ -50,3 +50,34 @@ array(3) {
["c3"]=>
NULL
}
--UEXPECT--
array(6) {
[0]=>
unicode(10) "2002-01-02"
[u"c1"]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[u"c2"]=>
unicode(8) "12:49:00"
[2]=>
NULL
[u"c3"]=>
NULL
}
array(3) {
[0]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[2]=>
NULL
}
array(3) {
[u"c1"]=>
unicode(10) "2002-01-02"
[u"c2"]=>
unicode(8) "12:49:00"
[u"c3"]=>
NULL
}

View File

@ -44,3 +44,17 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -44,3 +44,17 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -79,3 +79,41 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -32,3 +32,18 @@ array(6) {
["bar.c3"]=>
string(1) "6"
}
--UEXPECT--
array(6) {
[u"foo.c1"]=>
unicode(1) "1"
[u"foo.c2"]=>
unicode(1) "2"
[u"foo.c3"]=>
unicode(1) "3"
[u"bar.c1"]=>
unicode(1) "4"
[u"bar.c2"]=>
unicode(1) "5"
[u"bar.c3"]=>
unicode(1) "6"
}

View File

@ -36,3 +36,13 @@ string(3) "foo"
string(3) "bar"
string(3) "baz"
DONE!
--UEXPECT--
Buffered
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "baz"
Unbuffered
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "baz"
DONE!

View File

@ -76,3 +76,35 @@ string(4) "four"
NULL
NULL
DONE!
--UEXPECT--
====BUFFERED====
array(2) {
[0]=>
unicode(3) "one"
[1]=>
unicode(3) "two"
}
unicode(3) "one"
unicode(3) "two"
unicode(3) "one"
unicode(3) "two"
array(2) {
[0]=>
unicode(5) "three"
[1]=>
unicode(4) "four"
}
unicode(5) "three"
unicode(4) "four"
unicode(5) "three"
unicode(4) "four"
====UNBUFFERED====
unicode(3) "one"
unicode(3) "two"
NULL
NULL
unicode(5) "three"
unicode(4) "four"
NULL
NULL
DONE!

View File

@ -118,3 +118,80 @@ array(3) {
}
}
DONE!
--UEXPECTF--
unbuffered twice
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
Warning: sqlite_fetch_all(): One or more rowsets were already returned; returning NULL this time in %ssqlite_014.php on line %d
array(0) {
}
unbuffered with fetch_array
array(1) {
[0]=>
unicode(3) "one"
}
array(2) {
[0]=>
array(1) {
[0]=>
unicode(3) "two"
}
[1]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
buffered
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
bool(false)
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
DONE!

View File

@ -47,3 +47,22 @@ array(3) {
}
}
DONE!
--UEXPECTF--
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
DONE!

View File

@ -43,3 +43,11 @@ string(5) "three"
string(3) "one"
string(5) "three"
DONE!
--UEXPECT--
====BUFFERED====
unicode(3) "one"
unicode(5) "three"
====UNBUFFERED====
unicode(3) "one"
unicode(5) "three"
DONE!

View File

@ -45,3 +45,25 @@ array(1) {
[0]=>
string(1) "5"
}
--UEXPECTF--
unicode(1) "5"
unicode(1) "4"
unicode(5) "5data"
array(4) {
[0]=>
unicode(1) "1"
[1]=>
unicode(1) "2"
[2]=>
unicode(1) "3"
[3]=>
unicode(1) "4"
}
Warning: sqlite_single_query(): no such table: test in %s on line %d
bool(false)
NULL
array(1) {
[0]=>
unicode(1) "5"
}

View File

@ -99,3 +99,64 @@ array(1) {
string(5) "three"
}
====DONE!====
--UEXPECTF--
====SEEK:-1====
Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:0====
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:1====
array(1) {
[0]=>
unicode(3) "two"
}
====SEEK:2====
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:3====
Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====AGAIN====
====SEEK:-1====
Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:0====
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:1====
array(1) {
[0]=>
unicode(3) "two"
}
====SEEK:2====
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:3====
Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====DONE!====

View File

@ -103,3 +103,53 @@ bool(false)
Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d
====DONE!====
--UEXPECTF--
====TRAVERSE====
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
====REVERSE====
array(1) {
[0]=>
unicode(5) "three"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(3) "one"
}
====UNBUFFERED====
====TRAVERSE====
Warning: sqlite_rewind(): Cannot rewind an unbuffered result set in %ssqlite_023.php on line %d
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
====REVERSE====
Warning: sqlite_prev(): you cannot use sqlite_prev on unbuffered querys in %ssqlite_023.php on line %d
bool(false)
Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d
====DONE!====

View File

@ -74,3 +74,34 @@ object(stdClass)#%d (1) {
string(5) "three"
}
====DONE!====
--UEXPECTF--
====class24====
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(3) "one"
}
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(3) "two"
}
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(5) "three"
}
====stdclass====
object(stdClass)#%d (1) {
[u"a"]=>
unicode(3) "one"
}
object(stdClass)#%d (1) {
[u"a"]=>
unicode(3) "two"
}
object(stdClass)#%d (1) {
[u"a"]=>
unicode(5) "three"
}
====DONE!====

View File

@ -35,4 +35,17 @@ object(stdClass)#2 (1) {
object(stdClass)#1 (1) {
["a"]=>
string(5) "three"
}
}
--UEXPECTF--
object(stdClass)#1 (1) {
[u"a"]=>
unicode(3) "one"
}
object(stdClass)#2 (1) {
[u"a"]=>
unicode(3) "two"
}
object(stdClass)#1 (1) {
[u"a"]=>
unicode(5) "three"
}

View File

@ -25,3 +25,14 @@ array(4) {
["d"]=>
string(0) ""
}
--UEXPECT--
array(4) {
[u"a"]=>
unicode(0) ""
[u"b"]=>
unicode(7) "INTEGER"
[u"c"]=>
unicode(11) "VARCHAR(10)"
[u"d"]=>
unicode(0) ""
}

View File

@ -39,3 +39,26 @@ array(6) {
["c3"]=>
NULL
}
--UEXPECTF--
object(SQLiteDatabase)#%d (0) {
}
object(SQLiteResult)#%d (0) {
}
object(SQLiteResult)#%d (0) {
}
object(SQLiteResult)#%d (0) {
}
array(6) {
[0]=>
unicode(10) "2002-01-02"
[u"c1"]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[u"c2"]=>
unicode(8) "12:49:00"
[2]=>
NULL
[u"c3"]=>
NULL
}

View File

@ -49,3 +49,34 @@ array(3) {
["c3"]=>
NULL
}
--UEXPECT--
array(6) {
[0]=>
unicode(10) "2002-01-02"
[u"c1"]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[u"c2"]=>
unicode(8) "12:49:00"
[2]=>
NULL
[u"c3"]=>
NULL
}
array(3) {
[0]=>
unicode(10) "2002-01-02"
[1]=>
unicode(8) "12:49:00"
[2]=>
NULL
}
array(3) {
[u"c1"]=>
unicode(10) "2002-01-02"
[u"c2"]=>
unicode(8) "12:49:00"
[u"c3"]=>
NULL
}

View File

@ -41,3 +41,17 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -41,3 +41,17 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -42,3 +42,17 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -31,3 +31,18 @@ array(6) {
["bar.c3"]=>
string(1) "6"
}
--UEXPECT--
array(6) {
[u"foo.c1"]=>
unicode(1) "1"
[u"foo.c2"]=>
unicode(1) "2"
[u"foo.c3"]=>
unicode(1) "3"
[u"bar.c1"]=>
unicode(1) "4"
[u"bar.c2"]=>
unicode(1) "5"
[u"bar.c3"]=>
unicode(1) "6"
}

View File

@ -33,3 +33,13 @@ string(3) "foo"
string(3) "bar"
string(3) "baz"
DONE!
--UEXPECT--
Buffered
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "baz"
Unbuffered
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "baz"
DONE!

View File

@ -73,3 +73,35 @@ string(4) "four"
NULL
NULL
DONE!
--UEXPECT--
====BUFFERED====
array(2) {
[0]=>
unicode(3) "one"
[1]=>
unicode(3) "two"
}
unicode(3) "one"
unicode(3) "two"
unicode(3) "one"
unicode(3) "two"
array(2) {
[0]=>
unicode(5) "three"
[1]=>
unicode(4) "four"
}
unicode(5) "three"
unicode(4) "four"
unicode(5) "three"
unicode(4) "four"
====UNBUFFERED====
unicode(3) "one"
unicode(3) "two"
NULL
NULL
unicode(5) "three"
unicode(4) "four"
NULL
NULL
DONE!

View File

@ -116,3 +116,80 @@ array(3) {
}
}
DONE!
--UEXPECTF--
unbuffered twice
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
Warning: SQLiteUnbuffered::fetchAll(): One or more rowsets were already returned; returning NULL this time in %ssqlite_oo_014.php on line %d
array(0) {
}
unbuffered with fetch_array
array(1) {
[0]=>
unicode(3) "one"
}
array(2) {
[0]=>
array(1) {
[0]=>
unicode(3) "two"
}
[1]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
buffered
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
bool(false)
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
DONE!

View File

@ -45,3 +45,22 @@ array(3) {
}
}
DONE!
--UEXPECTF--
array(3) {
[0]=>
array(1) {
[0]=>
unicode(3) "one"
}
[1]=>
array(1) {
[0]=>
unicode(3) "two"
}
[2]=>
array(1) {
[0]=>
unicode(5) "three"
}
}
DONE!

View File

@ -40,3 +40,11 @@ string(5) "three"
string(3) "one"
string(5) "three"
DONE!
--UEXPECT--
====BUFFERED====
unicode(3) "one"
unicode(5) "three"
====UNBUFFERED====
unicode(3) "one"
unicode(5) "three"
DONE!

View File

@ -64,3 +64,19 @@ array(2) {
string(4) "four"
}
DONE!
--UEXPECTF--
Message: sqlite_factory() expects at least 1 parameter, 0 given
File: %ssqlite_oo_020.php
array(2) {
[0]=>
unicode(3) "one"
[1]=>
unicode(3) "two"
}
array(2) {
[0]=>
unicode(5) "three"
[1]=>
unicode(4) "four"
}
DONE!

View File

@ -46,3 +46,26 @@ array(1) {
string(1) "5"
}
DONE!
--UEXPECTF--
unicode(1) "5"
unicode(1) "4"
unicode(5) "5data"
array(4) {
[0]=>
unicode(1) "1"
[1]=>
unicode(1) "2"
[2]=>
unicode(1) "3"
[3]=>
unicode(1) "4"
}
Warning: SQLiteDatabase::singleQuery(): no such table: test in %s on line %d
bool(false)
NULL
array(1) {
[0]=>
unicode(1) "5"
}
DONE!

View File

@ -96,3 +96,64 @@ array(1) {
string(5) "three"
}
====DONE!====
--UEXPECTF--
====SEEK:-1====
Warning: SQLiteResult::seek(): row -1 out of range in %ssqlite_oo_022.php on line %d
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:0====
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:1====
array(1) {
[0]=>
unicode(3) "two"
}
====SEEK:2====
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:3====
Warning: SQLiteResult::seek(): row 3 out of range in %ssqlite_oo_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====AGAIN====
====SEEK:-1====
Warning: SQLiteResult::seek(): row -1 out of range in %ssqlite_oo_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:0====
array(1) {
[0]=>
unicode(3) "one"
}
====SEEK:1====
array(1) {
[0]=>
unicode(3) "two"
}
====SEEK:2====
array(1) {
[0]=>
unicode(5) "three"
}
====SEEK:3====
Warning: SQLiteResult::seek(): row 3 out of range in %ssqlite_oo_022.php on line %d
array(1) {
[0]=>
unicode(5) "three"
}
====DONE!====

View File

@ -72,3 +72,34 @@ object(stdClass)#%d (1) {
string(5) "three"
}
====DONE!====
--UEXPECTF--
====class24====
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(3) "one"
}
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(3) "two"
}
class24::__construct
object(class24)#%d (1) {
[u"a"]=>
unicode(5) "three"
}
====stdclass====
object(stdClass)#%d (1) {
[u"a"]=>
unicode(3) "one"
}
object(stdClass)#%d (1) {
[u"a"]=>
unicode(3) "two"
}
object(stdClass)#%d (1) {
[u"a"]=>
unicode(5) "three"
}
====DONE!====

View File

@ -101,3 +101,57 @@ array(1) {
string(5) "three"
}
DONE!
--UEXPECT--
====UNBUFFERED====
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
====NO-MORE====
====DIRECT====
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
====BUFFERED====
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
array(1) {
[0]=>
unicode(3) "one"
}
array(1) {
[0]=>
unicode(3) "two"
}
array(1) {
[0]=>
unicode(5) "three"
}
DONE!

View File

@ -54,3 +54,19 @@ bool(true)
string(5) "three"
bool(true)
===DONE===
--UEXPECT--
====FOREACH====
unicode(3) "one"
unicode(3) "one"
unicode(3) "two"
unicode(3) "two"
unicode(5) "three"
unicode(5) "three"
====FOR====
unicode(3) "one"
bool(true)
unicode(3) "two"
bool(true)
unicode(5) "three"
bool(true)
===DONE===

View File

@ -23,3 +23,14 @@ array(4) {
["d"]=>
string(0) ""
}
--UEXPECT--
array(4) {
[u"a"]=>
unicode(0) ""
[u"b"]=>
unicode(7) "INTEGER"
[u"c"]=>
unicode(11) "VARCHAR(10)"
[u"d"]=>
unicode(0) ""
}

View File

@ -40,3 +40,12 @@ string(1) "1"
string(3) "PHP"
Fatal error: Call to undefined method foo::bar("php")() in %ssqlite_oo_030.php on line %d
--UEXPECTF--
NULL
unicode(1) "1"
unicode(3) "PHP"
NULL
unicode(1) "1"
unicode(3) "PHP"
Fatal error: Call to undefined method foo::bar("php")() in %ssqlite_oo_030.php on line %d