cvs: php4 /ext/fribidi README config.m4 fribidi.c fribidi.php php_fribidi.h

From: Date: Mon, 16 Sep 2002 15:31:33 +0000
Subject: cvs: php4 /ext/fribidi README config.m4 fribidi.c fribidi.php php_fribidi.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-14065@lists.php.net to get a copy of this message
sniper Mon Sep 16 11:31:33 2002 EDT Removed files: /php4/ext/fribidi fribidi.php Modified files: /php4/ext/fribidi README config.m4 fribidi.c php_fribidi.h Log: - Require Fribidi 0.10.4 -> no more glib needed. - Cleaned up a bit.

Index: php4/ext/fribidi/README diff -u php4/ext/fribidi/README:1.3 php4/ext/fribidi/README:1.4 --- php4/ext/fribidi/README:1.3 Sun Aug 19 02:39:13 2001 +++ php4/ext/fribidi/README Mon Sep 16 11:31:32 2002 @@ -35,10 +35,8 @@ Prerequisites ============= -1) FriBidi version 0.9.0 or later must be installed. Latest version can be obtained thru +1) FriBidi version 0.10.4 or later must be installed. Latest version can be obtained thru http://fribidi.sourceforge.net/ - -2) glib header files: glib.h and glibconfig.h. Note ===== Index: php4/ext/fribidi/config.m4 diff -u php4/ext/fribidi/config.m4:1.9 php4/ext/fribidi/config.m4:1.10 --- php4/ext/fribidi/config.m4:1.9 Sun Sep 15 05:32:29 2002 +++ php4/ext/fribidi/config.m4 Mon Sep 16 11:31:32 2002 @@ -1,79 +1,45 @@ dnl -dnl $Id: config.m4,v 1.9 2002/09/15 09:32:29 tal Exp $ +dnl $Id: config.m4,v 1.10 2002/09/16 15:31:32 sniper Exp $ dnl PHP_ARG_WITH(fribidi, for FriBidi support, -[ --with-fribidi[=DIR] Include fribidi support (requires FriBidi >=0.1.12).]) +[ --with-fribidi[=DIR] Include FriBidi support (requires FriBidi >= 0.10.4).]) if test "$PHP_FRIBIDI" != "no"; then -dnl if module was requested with default path of fribidi installation then -dnl $PHP_FRIBIDI will be "yes" - if test "$PHP_FRIBIDI" = "yes"; then PHP_FRIBIDI=/usr/local fi - dnl check for fribidi header files - - AC_MSG_CHECKING([for header files in "$PHP_FRIBIDI/include/fribidi"]) - if test -f $PHP_FRIBIDI/include/fribidi/fribidi.h && test -f $PHP_FRIBIDI/include/fribidi/fribidi_types.h && test -f $PHP_FRIBIDI/include/fribidi/fribidi_char_sets.h; then - FRIBIDI_INCDIR=$PHP_FRIBIDI/include/fribidi/ - AC_MSG_RESULT([found all]) - else - AC_MSG_RESULT([missing]) - fi - - dnl check for fribidi shared library - - AC_MSG_CHECKING([for libfribidi.so file in "$PHP_FRIBIDI/lib/"]) - if test -f "$PHP_FRIBIDI/lib/libfribidi.so" ; then - FRIBIDI_LIBDIR=$PHP_FRIBIDI/lib/ - AC_MSG_RESULT([found]) - else - AC_MSG_RESULT([missing]) - fi - - dnl check for glib header files - - AC_MSG_CHECKING([for glib header files]) - if test -f `which glib-config` ; then - AC_MSG_RESULT([found]) - GLIB_INCDIR=`glib-config --cflags` - else - AC_MSG_RESULT([missing]) - fi - - dnl check for fribidi version AC_MSG_CHECKING([for FriBidi version]) FRIBIDI_CONFIG=$PHP_FRIBIDI/bin/fribidi-config - if test -x $FRIBIDI_CONFIG; then + if test -x "$FRIBIDI_CONFIG"; then fribidi_version_full=`$FRIBIDI_CONFIG --version` + else + AC_MSG_ERROR([fribidi-config not found.]) fi - + fribidi_version=`echo ${fribidi_version_full} | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` - if test "$fribidi_version" -ge 9000; then + if test "$fribidi_version" -ge 10004; then AC_MSG_RESULT([$fribidi_version_full]) else - AC_MSG_ERROR(FriBidi version 0.9.0 or later is required to compile php with FriBidi support) + AC_MSG_ERROR([FriBidi version 0.10.4 or later required.]) fi + dnl Get the paths + FRIBIDI_LIBS=`$FRIBIDI_CONFIG --libs` + FRIBIDI_INCS=`$FRIBIDI_CONFIG --cflags` + + if test -n "$FRIBIDI_INCS" && test -n "$FRIBIDI_LIBS"; then + PHP_EVAL_INCLINE($FRIBIDI_INCS) + PHP_EVAL_LIBLINE($FRIBIDI_LIBS, FRIBIDI_SHARED_LIBADD) - AC_MSG_CHECKING([sanity to build extension]) - if test -n "$FRIBIDI_INCDIR" && test -n "$FRIBIDI_LIBDIR" && test -n "$GLIB_INCDIR"; then - - AC_MSG_RESULT([yes]) - - PHP_ADD_INCLUDE("$FRIBIDI_INCDIR") - PHP_EVAL_INCLINE("$GLIB_INCDIR") - PHP_ADD_LIBRARY_WITH_PATH(fribidi,"$FRIBIDI_LIBDIR", FRIBIDI_SHARED_LIBADD) - - AC_DEFINE(HAVE_FRIBIDI, 1, [ ]) PHP_NEW_EXTENSION(fribidi, fribidi.c, $ext_shared) PHP_SUBST(FRIBIDI_SHARED_LIBADD) + AC_DEFINE(HAVE_FRIBIDI, 1, [ ]) else - AC_MSG_RESULT([no]) + AC_MSG_ERROR([Could not find the required paths. Please check your FriBidi installation.]) fi fi Index: php4/ext/fribidi/fribidi.c diff -u php4/ext/fribidi/fribidi.c:1.16 php4/ext/fribidi/fribidi.c:1.17 --- php4/ext/fribidi/fribidi.c:1.16 Sun Sep 15 05:58:35 2002 +++ php4/ext/fribidi/fribidi.c Mon Sep 16 11:31:32 2002 @@ -17,38 +17,27 @@ +----------------------------------------------------------------------+ */ -/* $Id: fribidi.c,v 1.16 2002/09/15 09:58:35 tal Exp $ */ +/* $Id: fribidi.c,v 1.17 2002/09/16 15:31:32 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" -#include "php_ini.h" #include "php_fribidi.h" -#include "fribidi.h" -/* You should tweak config.m4 so this symbol (or some else suitable) - gets defined. -*/ #if HAVE_FRIBIDI -/* If you declare any globals in php_fribidi.h uncomment this: -ZEND_DECLARE_MODULE_GLOBALS(fribidi) -*/ +#include "ext/standard/info.h" +#include <fribidi/fribidi.h> -/* True global resources - no need for thread safety here */ -/* static int le_fribidi; */ - -/* Every user visible function must have an entry in fribidi_functions[]. -*/ function_entry fribidi_functions[] = { PHP_FE(fribidi_log2vis, NULL) - {NULL, NULL, NULL} /* Must be the last line in fribidi_functions[] */ + {NULL, NULL, NULL} }; zend_module_entry fribidi_module_entry = { - STANDARD_MODULE_HEADER, + STANDARD_MODULE_HEADER, "fribidi", fribidi_functions, PHP_MINIT(fribidi), @@ -56,7 +45,7 @@ NULL, NULL, PHP_MINFO(fribidi), - NO_VERSION_YET, + NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; @@ -92,7 +81,8 @@ PHP_MINFO_FUNCTION(fribidi) { php_info_print_table_start(); - php_info_print_table_header(2, "fribidi support", "enabled"); + php_info_print_table_header(2, "FriBidi support", "enabled"); + php_info_print_table_header(2, "FriBidi version", FRIBIDI_VERSION); php_info_print_table_end(); } /* }}} */ @@ -117,7 +107,7 @@ /* FRIBIDI_CHARSET_ISIRI_3342 */ /* */ /* Output: on success: The visual string. */ -/* on failure: */ +/* on failure: FALSE */ /*--------------------------------------------------------------*/ /* {{{ proto string fribidi_log2vis(string str, string direction, int charset) @@ -125,50 +115,36 @@ PHP_FUNCTION(fribidi_log2vis) { zval **parameter1, **parameter2, **parameter3; - - FriBidiChar *u_logical_str, *u_visual_str; /* unicode strings .... */ - char *inString; - guchar *outString; + char *inString, *outString; int len, alloc_len, utf8_len; - - FriBidiCharType base_dir; - FriBidiStrIndex *position_L_to_V_list; FriBidiStrIndex *position_V_to_L_list; - guint8 *embedding_level_list; + FriBidiLevel *embedding_level_list; /* get parameters from input */ - 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); /* allocate space and prepare all local variables */ - - len = Z_STRLEN_PP(parameter1); - inString = estrndup(Z_STRVAL_PP(parameter1), len); - alloc_len = len+1; u_logical_str = (FriBidiChar*) emalloc(sizeof(FriBidiChar)*alloc_len); u_visual_str = (FriBidiChar*) emalloc(sizeof(FriBidiChar)*alloc_len); - position_L_to_V_list = (FriBidiStrIndex*) emalloc(sizeof(FriBidiStrIndex)*alloc_len); - position_V_to_L_list = (FriBidiStrIndex*) emalloc(sizeof(FriBidiStrIndex)*alloc_len); - embedding_level_list = (guint8*) emalloc(sizeof(guint8)*alloc_len); + position_L_to_V_list = (FriBidiStrIndex *) emalloc(sizeof(FriBidiStrIndex)*alloc_len); + position_V_to_L_list = (FriBidiStrIndex *) emalloc(sizeof(FriBidiStrIndex)*alloc_len); + embedding_level_list = (FriBidiLevel *) emalloc(sizeof(FriBidiLevel)*alloc_len); - outString = (guchar*)emalloc(sizeof(guchar)*alloc_len); - if(inString[len-1] == '\n') { inString[len-1] = '\0'; } @@ -193,36 +169,36 @@ fribidi_isiri_3342_to_unicode(inString, len, u_logical_str); break; default: - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown charset"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset"); efree(u_logical_str); efree(u_visual_str); efree(position_L_to_V_list); efree(position_V_to_L_list); efree(embedding_level_list); - efree(outString); + efree(inString); RETURN_FALSE; } - /* visualize the logical.... */ - if ((Z_STRVAL_PP(parameter2))[0] == 'R') { base_dir = FRIBIDI_TYPE_RTL; - } else if (Z_STRVAL_PP(parameter2)[0] == 'L') + } else if (Z_STRVAL_PP(parameter2)[0] == 'L') { base_dir = FRIBIDI_TYPE_LTR; - else + } else { base_dir = FRIBIDI_TYPE_N; + } + + outString = (char *) emalloc(sizeof(char)*alloc_len); 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(Z_LVAL_PP(parameter3)) { case FRIBIDI_CHARSET_UTF8: - fribidi_unicode_to_utf8(u_visual_str, utf8_len , outString); + fribidi_unicode_to_utf8(u_visual_str, utf8_len, outString); break; case FRIBIDI_CHARSET_ISO8859_6: - fribidi_unicode_to_iso8859_6(u_visual_str, len , outString); + fribidi_unicode_to_iso8859_6(u_visual_str, len, outString); break; case FRIBIDI_CHARSET_ISO8859_8: fribidi_unicode_to_iso8859_8(u_visual_str, len , outString); @@ -237,28 +213,28 @@ fribidi_unicode_to_isiri_3342(u_visual_str, len , outString); break; default: - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown charset"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset"); efree(u_logical_str); efree(u_visual_str); efree(position_L_to_V_list); efree(position_V_to_L_list); efree(embedding_level_list); efree(outString); + efree(inString); RETURN_FALSE; } - efree(u_logical_str); efree(u_visual_str); - efree(position_L_to_V_list); efree(position_V_to_L_list); efree(embedding_level_list); - - RETURN_STRING(outString, 1); + efree(inString); + + RETVAL_STRING(outString, 1); + efree(outString); } /* }}} */ - #endif /* HAVE_FRIBIDI */ Index: php4/ext/fribidi/php_fribidi.h diff -u php4/ext/fribidi/php_fribidi.h:1.9 php4/ext/fribidi/php_fribidi.h:1.10 --- php4/ext/fribidi/php_fribidi.h:1.9 Sun Sep 15 05:32:29 2002 +++ php4/ext/fribidi/php_fribidi.h Mon Sep 16 11:31:32 2002 @@ -21,22 +21,11 @@ #if HAVE_FRIBIDI -#include "fribidi.h" -#include "../standard/info.h" -#include <glib.h> +#include <fribidi/fribidi.h> extern zend_module_entry fribidi_module_entry; #define phpext_fribidi_ptr &fribidi_module_entry - -typedef struct _php_fribidi_rsrc{ - guint16 *position_L_to_V_list; - guint16 *position_V_to_L_list; - guint8 *embedding_level_list; - guchar *out_string; -} php_fribidi_rsrc; - - #ifdef PHP_WIN32 #define PHP_FRIBIDI_API __declspec(dllexport) #else @@ -50,22 +39,6 @@ PHP_MINFO_FUNCTION(fribidi); PHP_FUNCTION(fribidi_log2vis); -/*void php_fribidi_free_rsrc(php_fribidi_rsrc* p_rsrc);*/ -/* - Declare any global variables you may need between the BEGIN - and END macros here: - -ZEND_BEGIN_MODULE_GLOBALS(fribidi) - int global_variable; -ZEND_END_MODULE_GLOBALS(fribidi) -*/ - -/* In every function that needs to use variables in php_fribidi_globals, - do call FRIBIDILS_FETCH(); after declaring other variables used by - that function, and always refer to them as FRIBIDIG(variable). - You are encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ #ifdef ZTS #define FRIBIDIG(v) TSRMG(fribidi_globals_id, php_fribidi_globals *, v) @@ -80,7 +53,6 @@ #endif #endif /* PHP_FRIBIDI_H */ - /* * Local variables:
« previous php.cvs (#14065) next »