tal Thu Sep 26 06:43:42 2002 EDT Modified files: /php4/ext/fribidi fribidi.c README Log: - Reverted back to old param parsing api (and eliminated a segfault by doing that) - Added the CapRTL charset -- should be used for testing on machines without Hebrew/Arabic/Persian fonts - Changed the note about deprecated behaviour from E_WARNING to E_NOTICE Index: php4/ext/fribidi/fribidi.c diff -u php4/ext/fribidi/fribidi.c:1.23 php4/ext/fribidi/fribidi.c:1.24 --- php4/ext/fribidi/fribidi.c:1.23 Wed Sep 25 09:49:55 2002 +++ php4/ext/fribidi/fribidi.c Thu Sep 26 06:43:42 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fribidi.c,v 1.23 2002/09/25 13:49:55 tal Exp $ */ +/* $Id: fribidi.c,v 1.24 2002/09/26 10:43:42 tal Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -64,6 +64,7 @@ REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CP1255", FRIBIDI_CHARSET_CP1255, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CP1256", FRIBIDI_CHARSET_CP1256, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_ISIRI_3342", FRIBIDI_CHARSET_ISIRI_3342, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_CAP_RTL", FRIBIDI_CHARSET_CAP_RTL, +CONST_CS | CONST_PERSISTENT); /* Directions */ REGISTER_LONG_CONSTANT("FRIBIDI_AUTO", FRIBIDI_TYPE_ON, CONST_CS | CONST_PERSISTENT); @@ -102,7 +103,7 @@ | Possible values: | | a) FRIBIDI_LTR - left to right. | | b) FRIBIDI_RTL - right to left. | -| c) FRIBIDI_AUTO - autodetected by the BiDi | +| c) FRIBIDI_AUTO - autodetected by the Unicode | | BiDi algorithm. | | 3) Character code being used - | | Possible values (i.e., charsets supported) | @@ -112,31 +113,35 @@ | FRIBIDI_CHARSET_CP1255 | | FRIBIDI_CHARSET_CP1256 | | FRIBIDI_CHARSET_ISIRI_3342 | +| FRIBIDI_CHARSET_CAP_RTL | | | | Output: on success: The visual string. | | on failure: FALSE | +------------------------------------------------------------+ */ -/* {{{ proto string fribidi_log2vis(string v_str, long direction, long charset) +/* {{{ proto string fribidi_log2vis(string logical_str, long direction, long charset) Convert a logical string to a visual one */ PHP_FUNCTION(fribidi_log2vis) { - zval **direction; - long charset; + zval **logical_str, **direction, **charset; FriBidiChar *u_logical_str, *u_visual_str; /* unicode strings .... */ - char *v_str, *in_string, *out_string; + char *in_string, *out_string; int len, alloc_len; FriBidiCharType base_dir; FriBidiStrIndex *position_L_to_V_list; FriBidiStrIndex *position_V_to_L_list; FriBidiLevel *embedding_level_list; - - /* parse parameters from input */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szl", &v_str, &len, &direction, &charset) == FAILURE) { - return; + + /* get parameters from input */ + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &logical_str, +&direction, &charset) == FAILURE) { + WRONG_PARAM_COUNT; } + /* convert argument types */ + convert_to_string_ex(logical_str); + convert_to_long_ex(charset); + if (Z_TYPE_PP(direction) == IS_LONG) { convert_to_long_ex(direction); base_dir = Z_LVAL_PP(direction); @@ -150,11 +155,11 @@ base_dir = FRIBIDI_TYPE_ON; } - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The use of strings to mark the base direction is deprecated, please use the FRIBIDI_LTR, FRIBIDI_RTL and FRIBIDI_AUTO constants"); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The use of strings to mark +the base direction is deprecated, please use the FRIBIDI_LTR, FRIBIDI_RTL and +FRIBIDI_AUTO constants"); } /* allocate space and prepare all local variables */ - in_string = estrndup(v_str, len); + in_string = estrndup(Z_STRVAL_PP(logical_str), len); alloc_len = len+1; u_logical_str = (FriBidiChar*) emalloc(sizeof(FriBidiChar)*alloc_len); @@ -168,14 +173,15 @@ in_string[len-1] = '\0'; } - switch(charset) { + switch(Z_LVAL_PP(charset)) { case FRIBIDI_CHARSET_UTF8: case FRIBIDI_CHARSET_ISO8859_6: case FRIBIDI_CHARSET_ISO8859_8: case FRIBIDI_CHARSET_CP1255: case FRIBIDI_CHARSET_CP1256: case FRIBIDI_CHARSET_ISIRI_3342: - len = fribidi_charset_to_unicode(charset, in_string, len, u_logical_str); + case FRIBIDI_CHARSET_CAP_RTL: + len = fribidi_charset_to_unicode(Z_LVAL_PP(charset), +in_string, len, u_logical_str); break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset"); @@ -195,14 +201,15 @@ fribidi_log2vis(u_logical_str, len, &base_dir, u_visual_str, position_L_to_V_list, position_V_to_L_list, embedding_level_list); /* convert back to original char set */ - switch(charset) { + switch(Z_LVAL_PP(charset)) { case FRIBIDI_CHARSET_UTF8: case FRIBIDI_CHARSET_ISO8859_6: case FRIBIDI_CHARSET_ISO8859_8: case FRIBIDI_CHARSET_CP1255: case FRIBIDI_CHARSET_CP1256: case FRIBIDI_CHARSET_ISIRI_3342: - fribidi_unicode_to_charset(charset, u_visual_str, len, out_string); + case FRIBIDI_CHARSET_CAP_RTL: + fribidi_unicode_to_charset(Z_LVAL_PP(charset), u_visual_str, +len, out_string); break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset"); Index: php4/ext/fribidi/README diff -u php4/ext/fribidi/README:1.5 php4/ext/fribidi/README:1.6 --- php4/ext/fribidi/README:1.5 Tue Sep 17 12:27:27 2002 +++ php4/ext/fribidi/README Thu Sep 26 06:43:42 2002 @@ -18,12 +18,13 @@ c) FRIBIDI_AUTO - autodetect the base direction 3) The char code being used, which can be one of the following constants: - a) FRIBIDI_CHARSET_UTF8 - b) FRIBIDI_CHARSET_8859_6 - c) FRIBIDI_CHARSET_8859_8 - d) FRIBIDI_CHARSET_CP1255 - e) FRIBIDI_CHARSET_CP1256 - f) FRIBIDI_CHARSET_ISIRI_3342 + a) FRIBIDI_CHARSET_UTF8 (Unicode) + b) FRIBIDI_CHARSET_8859_6 (Arabic) + c) FRIBIDI_CHARSET_8859_8 (Hebrew) + d) FRIBIDI_CHARSET_CP1255 (Hebrew/Yiddish) + e) FRIBIDI_CHARSET_CP1256 (Arabic) + f) FRIBIDI_CHARSET_ISIRI_3342 (Persian) + g) FRIBIDI_CHARSET_CAP_RTL - Used for test purposes, will treat CAPS +as non-English letetrs Note: Currently, FriBidi supports the above Character Codes alone.
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php