cvs: ZendEngine2 / zend.c zend.h zend_API.h zend_globals.h zend_unicode.c zend_unicode.h
| From: | Andrei Zmievski | Date: | Thu, 04 May 2006 21:22:17 +0000 |
| Subject: | cvs: ZendEngine2 / zend.c zend.h zend_API.h zend_globals.h zend_unicode.c zend_unicode.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4832@lists.php.net to get a copy of this message | ||
andrei Thu May 4 21:22:17 2006 UTC
Modified files:
/ZendEngine2 zend.c zend.h zend_API.h zend_globals.h zend_unicode.c
zend_unicode.h
Log:
Add a global ASCII connverter, macros to return single codepoints
(UCHAR32), and zend_unicode_to_ascii() function.
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend.c?r1=1.352&r2=1.353&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.352 ZendEngine2/zend.c:1.353
--- ZendEngine2/zend.c:1.352 Thu Apr 20 21:56:43 2006
+++ ZendEngine2/zend.c Thu May 4 21:22:17 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.c,v 1.352 2006/04/20 21:56:43 andrei Exp $ */
+/* $Id: zend.c,v 1.353 2006/05/04 21:22:17 andrei Exp $ */
#include "zend.h"
#include "zend_extensions.h"
@@ -42,10 +42,8 @@
# define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
#endif
-#ifndef __GNUC__
ZEND_API zstr null_zstr;
ZEND_API zstr empty_zstr;
-#endif
#if defined(ZEND_WIN32) && ZEND_DEBUG
BOOL WINAPI IsDebuggerPresent(VOID);
@@ -906,6 +904,7 @@
{
unicode_globals->unicode = 0;
unicode_globals->utf8_conv = NULL;
+ unicode_globals->ascii_conv = NULL;
unicode_globals->fallback_encoding_conv = NULL;
unicode_globals->runtime_encoding_conv = NULL;
unicode_globals->output_encoding_conv = NULL;
@@ -913,6 +912,8 @@
unicode_globals->http_input_encoding_conv = NULL;
unicode_globals->filesystem_encoding_conv = NULL;
zend_set_converter_encoding(&unicode_globals->utf8_conv, "UTF-8");
+ zend_set_converter_encoding(&unicode_globals->ascii_conv, "US-ASCII");
+ zend_set_converter_error_mode(unicode_globals->ascii_conv, ZEND_FROM_UNICODE,
ZEND_CONV_ERROR_STOP);
unicode_globals->from_error_mode = ZEND_CONV_ERROR_SUBST;
memset(unicode_globals->from_subst_char, 0, 3 * sizeof(UChar));
zend_codepoint_to_uchar(0x3f, unicode_globals->from_subst_char);
@@ -941,6 +942,9 @@
if (unicode_globals->utf8_conv) {
ucnv_close(unicode_globals->utf8_conv);
}
+ if (unicode_globals->ascii_conv) {
+ ucnv_close(unicode_globals->ascii_conv);
+ }
zend_hash_destroy(&unicode_globals->flex_compatible);
}
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend.h?r1=1.318&r2=1.319&diff_format=u
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.318 ZendEngine2/zend.h:1.319
--- ZendEngine2/zend.h:1.318 Thu Mar 30 21:39:15 2006
+++ ZendEngine2/zend.h Thu May 4 21:22:17 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.h,v 1.318 2006/03/30 21:39:15 tony2001 Exp $ */
+/* $Id: zend.h,v 1.319 2006/05/04 21:22:17 andrei Exp $ */
#ifndef ZEND_H
#define ZEND_H
@@ -246,11 +246,6 @@
void *v;
} zstr;
-#ifdef __GNUC__
-# define ZSTR(x) ((zstr)(x))
-# define NULL_ZSTR ZSTR((void*)NULL)
-# define EMPTY_ZSTR ZSTR("\0\0")
-#else
extern ZEND_API zstr null_zstr;
extern ZEND_API zstr empty_zstr;
@@ -263,7 +258,6 @@
# define ZSTR(x) _to_zstr(x)
# define NULL_ZSTR null_zstr
# define EMPTY_ZSTR empty_zstr
-#endif
#define EMPTY_STR ((UChar*)"\0\0")
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.h?r1=1.240&r2=1.241&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.240 ZendEngine2/zend_API.h:1.241
--- ZendEngine2/zend_API.h:1.240 Thu Apr 6 18:02:39 2006
+++ ZendEngine2/zend_API.h Thu May 4 21:22:17 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.240 2006/04/06 18:02:39 pollita Exp $ */
+/* $Id: zend_API.h,v 1.241 2006/05/04 21:22:17 andrei Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -807,6 +807,12 @@
Z_TYPE_P(z) = IS_UNICODE; \
}
+#define ZVAL_UCHAR32(z, ch) { \
+ UChar buf[3]; \
+ int buf_len = zend_codepoint_to_uchar(ch, buf); \
+ ZVAL_UNICODEL(z, buf, buf_len, 1); \
+}
+
#define ZVAL_EMPTY_STRING(z) { \
Z_STRLEN_P(z) = 0; \
Z_STRVAL_P(z) = STR_EMPTY_ALLOC(); \
@@ -881,6 +887,7 @@
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
#define RETVAL_UNICODE(u, duplicate) ZVAL_UNICODE(return_value, u, duplicate)
#define RETVAL_UNICODEL(u, l, duplicate) ZVAL_UNICODEL(return_value, u, l, duplicate)
+#define RETVAL_UCHAR32(ch) ZVAL_UCHAR32(return_value, ch)
#define RETVAL_EMPTY_UNICODE() ZVAL_EMPTY_UNICODE(return_value)
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
#define RETVAL_FALSE ZVAL_BOOL(return_value, 0)
@@ -899,6 +906,7 @@
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
#define RETURN_UNICODE(u, duplicate) { RETVAL_UNICODE(u, duplicate); return; }
#define RETURN_UNICODEL(u, l, duplicate) { RETVAL_UNICODEL(u, l, duplicate); return; }
+#define RETURN_UCHAR32(ch) { RETVAL_UCHAR32(ch); return; }
#define RETURN_EMPTY_UNICODE() { RETVAL_EMPTY_UNICODE(); return; }
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
#define RETURN_FALSE { RETVAL_FALSE; return; }
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_globals.h?r1=1.156&r2=1.157&diff_format=u
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.156 ZendEngine2/zend_globals.h:1.157
--- ZendEngine2/zend_globals.h:1.156 Thu Apr 20 21:56:43 2006
+++ ZendEngine2/zend_globals.h Thu May 4 21:22:17 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.156 2006/04/20 21:56:43 andrei Exp $ */
+/* $Id: zend_globals.h,v 1.157 2006/05/04 21:22:17 andrei Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -301,6 +301,7 @@
UConverter *http_input_encoding_conv;/* http input encoding converter */
UConverter *filesystem_encoding_conv;/* default filesystem converter (entries, not contents) */
UConverter *utf8_conv; /* all-purpose UTF-8 converter */
+ UConverter *ascii_conv; /* all-purpose ASCII converter */
uint16_t from_error_mode;
UChar from_subst_char[3];
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_unicode.c?r1=1.21&r2=1.22&diff_format=u
Index: ZendEngine2/zend_unicode.c
diff -u ZendEngine2/zend_unicode.c:1.21 ZendEngine2/zend_unicode.c:1.22
--- ZendEngine2/zend_unicode.c:1.21 Thu Apr 20 21:56:43 2006
+++ ZendEngine2/zend_unicode.c Thu May 4 21:22:17 2006
@@ -373,6 +373,23 @@
}
/* }}} */
+/* {{{ zend_unicode_to_ascii */
+ZEND_API char* zend_unicode_to_ascii(const UChar *us, int us_len TSRMLS_DC)
+{
+ char *cs;
+ int cs_len;
+ UErrorCode status = U_ZERO_ERROR;
+
+ zend_convert_from_unicode(UG(ascii_conv), &cs, &cs_len, us, us_len, &status);
+ if (U_FAILURE(status)) {
+ efree(cs);
+ return NULL;
+ }
+
+ return cs;
+}
+/* }}} */
+
/* {{{ zend_raise_conversion_error_ex */
ZEND_API void zend_raise_conversion_error_ex(char *message, UConverter *conv, zend_conv_direction
dir, int error_char_offset, int use_exception TSRMLS_DC)
{
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_unicode.h?r1=1.15&r2=1.16&diff_format=u
Index: ZendEngine2/zend_unicode.h
diff -u ZendEngine2/zend_unicode.h:1.15 ZendEngine2/zend_unicode.h:1.16
--- ZendEngine2/zend_unicode.h:1.15 Thu Apr 20 21:56:43 2006
+++ ZendEngine2/zend_unicode.h Thu May 4 21:22:17 2006
@@ -73,6 +73,8 @@
ZEND_API int zend_convert_to_unicode(UConverter *conv, UChar **target, int *target_len, const char
*source, int source_len, UErrorCode *status);
ZEND_API int zend_convert_from_unicode(UConverter *conv, char **target, int *target_len, const
UChar *source, int source_len, UErrorCode *status);
ZEND_API void zend_convert_encodings(UConverter *target_conv, UConverter *source_conv, char
**target, int *target_len, const char *source, int source_len, UErrorCode *status);
+ZEND_API char* zend_unicode_to_ascii(const UChar *us, int us_len TSRMLS_DC);
+
ZEND_API int zval_string_to_unicode_ex(zval *string, UConverter *conv TSRMLS_DC);
ZEND_API int zval_string_to_unicode(zval *string TSRMLS_DC);
ZEND_API int zval_unicode_to_string(zval *string, UConverter *conv TSRMLS_DC);