tal Tue Sep 17 12:27:27 2002 EDT
Modified files:
/php4/ext/fribidi README fribidi.c
Log:
* The second argument of
fribidi_log2vis now accepts a constant.
The old way (using strings) is still available
but deprecated.
Index: php4/ext/fribidi/README
diff -u php4/ext/fribidi/README:1.4 php4/ext/fribidi/README:1.5
--- php4/ext/fribidi/README:1.4 Mon Sep 16 11:31:32 2002
+++ php4/ext/fribidi/README Tue Sep 17 12:27:27 2002
@@ -9,9 +9,13 @@
Usage
=====
- The only function used is fribidi_log2vis (logical to visual).
- Input: 1) The Logical string.
- 2) Base direction of application - 'L' or 'R'.
+ The only function used is fribidi_log2vis (logical [non-reversed] to visual
+[reversed]).
+ Input:
+ 1) The Logical string.
+ 2) Base direction of application. Possible values:
+ a) FRIBIDI_RTL - right to left
+ b) FRIBIDI_LTR - left to right
+ 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
@@ -43,7 +47,7 @@
The function fribidi_log2vis computes three more arrays which are currently not
passed back as output.
These arrays are:
- 1) mapping from the logical to the visual sting.
+ 1) mapping from the logical to the visual string.
2) mapping from the visual to the logical string.
3) embedding level of characters as figured out by the FriBidi algorithm.
Index: php4/ext/fribidi/fribidi.c
diff -u php4/ext/fribidi/fribidi.c:1.17 php4/ext/fribidi/fribidi.c:1.18
--- php4/ext/fribidi/fribidi.c:1.17 Mon Sep 16 11:31:32 2002
+++ php4/ext/fribidi/fribidi.c Tue Sep 17 12:27:27 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fribidi.c,v 1.17 2002/09/16 15:31:32 sniper Exp $ */
+/* $Id: fribidi.c,v 1.18 2002/09/17 16:27:27 tal Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -57,13 +57,19 @@
*/
PHP_MINIT_FUNCTION(fribidi)
{
+ /* Charsets */
REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_UTF8", FRIBIDI_CHARSET_UTF8, CONST_CS
| CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_8859_6", FRIBIDI_CHARSET_ISO8859_6,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FRIBIDI_CHARSET_8859_8", FRIBIDI_CHARSET_ISO8859_8,
CONST_CS | CONST_PERSISTENT);
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);
-
+
+ /* Directions */
+ REGISTER_LONG_CONSTANT("FRIBIDI_AUTO", FRIBIDI_TYPE_ON, CONST_CS |
+CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FRIBIDI_LTR", FRIBIDI_TYPE_LTR, CONST_CS |
+CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("FRIBIDI_RTL", FRIBIDI_TYPE_RTL, CONST_CS |
+CONST_PERSISTENT);
+
return SUCCESS;
}
/* }}} */
@@ -127,12 +133,27 @@
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, ¶meter1,
¶meter2, ¶meter3) == FAILURE) {
WRONG_PARAM_COUNT;
}
-
+
/* convert input to expected type.... */
convert_to_string_ex(parameter1);
- convert_to_string_ex(parameter2);
convert_to_long_ex(parameter3);
-
+
+ if (Z_TYPE_PP(parameter2) == IS_LONG) {
+ convert_to_long_ex(parameter2);
+ base_dir = Z_LVAL_PP(parameter2);
+ } else if (Z_TYPE_PP(parameter2) == IS_STRING) {
+ convert_to_string_ex(parameter2);
+ if ((Z_STRVAL_PP(parameter2))[0] == 'R') {
+ base_dir = FRIBIDI_TYPE_RTL;
+ } else if (Z_STRVAL_PP(parameter2)[0] == 'L') {
+ base_dir = FRIBIDI_TYPE_LTR;
+ } else {
+ 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");
+ }
+
/* allocate space and prepare all local variables */
len = Z_STRLEN_PP(parameter1);
inString = estrndup(Z_STRVAL_PP(parameter1), len);
@@ -180,13 +201,6 @@
}
/* visualize the logical.... */
- if ((Z_STRVAL_PP(parameter2))[0] == 'R') {
- base_dir = FRIBIDI_TYPE_RTL;
- } else if (Z_STRVAL_PP(parameter2)[0] == 'L') {
- base_dir = FRIBIDI_TYPE_LTR;
- } else {
- base_dir = FRIBIDI_TYPE_N;
- }
outString = (char *) emalloc(sizeof(char)*alloc_len);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php