* The second argument of

fribidi_log2vis now accepts a constant.
The old way (using strings) is still available
but deprecated.
This commit is contained in:
Tal Peer 2002-09-17 16:27:27 +00:00
parent 91b0d03346
commit e9ccb81903
2 changed files with 33 additions and 15 deletions

View File

@ -9,9 +9,13 @@ Arabic/Hebrew embedded within English is such a case.
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 @@ Note
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.

View File

@ -57,13 +57,19 @@ ZEND_GET_MODULE(fribidi)
*/
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 @@ PHP_FUNCTION(fribidi_log2vis)
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &parameter1, &parameter2, &parameter3) == 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 @@ PHP_FUNCTION(fribidi_log2vis)
}
/* 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);