andrei Sat Feb 4 00:35:37 2006 UTC
Modified files:
/php-src/ext/unicode unicode_iterators.c
Log:
Add code unit ops.
http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/unicode_iterators.c?r1=1.8&r2=1.9&diff_format=u
Index: php-src/ext/unicode/unicode_iterators.c
diff -u php-src/ext/unicode/unicode_iterators.c:1.8
php-src/ext/unicode/unicode_iterators.c:1.9
--- php-src/ext/unicode/unicode_iterators.c:1.8 Sat Feb 4 00:23:52 2006
+++ php-src/ext/unicode/unicode_iterators.c Sat Feb 4 00:35:37 2006
@@ -14,8 +14,15 @@
+----------------------------------------------------------------------+
*/
-/* $Id: unicode_iterators.c,v 1.8 2006/02/04 00:23:52 andrei Exp $ */
+/* $Id: unicode_iterators.c,v 1.9 2006/02/04 00:35:37 andrei Exp $ */
+/*
+ * TODO
+ *
+ * - optimize current() to pass return_value to the handler so that it fills it
+ * in directly instead of creating a new zval
+ * - return code units as binary strings? integers? or leave as unicode
strings?
+ */
#include "php.h"
#include "zend_interfaces.h"
@@ -63,7 +70,48 @@
/* Code unit ops */
+static int text_iter_cu_valid(text_iter_obj* object TSRMLS_DC)
+{
+ return (object->u.cu.index < object->text_len);
+}
+
+static void text_iter_cu_current(text_iter_obj* object TSRMLS_DC)
+{
+ if (!object->current) {
+ MAKE_STD_ZVAL(object->current);
+ ZVAL_UNICODEL(object->current, object->text +
object->u.cu.index, 1, 1);
+ }
+}
+
+static int text_iter_cu_key(text_iter_obj* object TSRMLS_DC)
+{
+ return object->u.cu.index;
+}
+
+static void text_iter_cu_next(text_iter_obj* object TSRMLS_DC)
+{
+ object->u.cu.index++;
+ if (object->current) {
+ zval_ptr_dtor(&object->current);
+ object->current = NULL;
+ }
+}
+
+static void text_iter_cu_rewind(text_iter_obj *object TSRMLS_DC)
+{
+ object->u.cu.index = 0;
+ if (object->current) {
+ zval_ptr_dtor(&object->current);
+ object->current = NULL;
+ }
+}
+
static text_iter_ops text_iter_cu_ops = {
+ text_iter_cu_valid,
+ text_iter_cu_current,
+ text_iter_cu_key,
+ text_iter_cu_next,
+ text_iter_cu_rewind,
};
/* Code point ops */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php