summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2002-09-16 15:31:32 +0000
committerfoobar <sniper@php.net>2002-09-16 15:31:32 +0000
commitaef1c680bc2bbe26d308dd2da710cf649c688532 (patch)
tree042777602f3c788bafa120bddd374ce0cbfa6d23 /ext
parent55362251c8a0298884fba5ecf82fd58f665592be (diff)
downloadphp-git-aef1c680bc2bbe26d308dd2da710cf649c688532.tar.gz
- Require Fribidi 0.10.4 -> no more glib needed.
- Cleaned up a bit.
Diffstat (limited to 'ext')
-rw-r--r--ext/fribidi/README4
-rw-r--r--ext/fribidi/config.m466
-rwxr-xr-xext/fribidi/fribidi.c80
-rw-r--r--ext/fribidi/fribidi.php10
-rw-r--r--ext/fribidi/php_fribidi.h30
5 files changed, 46 insertions, 144 deletions
diff --git a/ext/fribidi/README b/ext/fribidi/README
index db96b170a4..6620388248 100644
--- a/ext/fribidi/README
+++ b/ext/fribidi/README
@@ -35,11 +35,9 @@ Compiling
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
=====
diff --git a/ext/fribidi/config.m4 b/ext/fribidi/config.m4
index 7e48b71d17..b3bd80c162 100644
--- a/ext/fribidi/config.m4
+++ b/ext/fribidi/config.m4
@@ -3,77 +3,43 @@ dnl $Id$
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
diff --git a/ext/fribidi/fribidi.c b/ext/fribidi/fribidi.c
index fc78f5315e..7ba3e5c8af 100755
--- a/ext/fribidi/fribidi.c
+++ b/ext/fribidi/fribidi.c
@@ -24,31 +24,20 @@
#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 @@ zend_module_entry fribidi_module_entry = {
NULL,
NULL,
PHP_MINFO(fribidi),
- NO_VERSION_YET,
+ NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
@@ -92,7 +81,8 @@ PHP_MSHUTDOWN_FUNCTION(fribidi)
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 @@ PHP_MINFO_FUNCTION(fribidi)
/* 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_MINFO_FUNCTION(fribidi)
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 @@ PHP_FUNCTION(fribidi_log2vis)
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,29 +213,29 @@ PHP_FUNCTION(fribidi_log2vis)
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 */
/*
diff --git a/ext/fribidi/fribidi.php b/ext/fribidi/fribidi.php
deleted file mode 100644
index 6a603d604e..0000000000
--- a/ext/fribidi/fribidi.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?
-$module = 'fribidi';
-$function = 'confirm_' . $module . '_compiled';
-if (extension_loaded($module)) {
- $str = $function($module);
-} else {
- $str = "Module $module is not compiled into PHP";
-}
-echo "$str\n";
-?>
diff --git a/ext/fribidi/php_fribidi.h b/ext/fribidi/php_fribidi.h
index 757a1d6d68..7e602bbf46 100644
--- a/ext/fribidi/php_fribidi.h
+++ b/ext/fribidi/php_fribidi.h
@@ -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_RSHUTDOWN_FUNCTION(fribidi);
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)
@@ -81,7 +54,6 @@ ZEND_END_MODULE_GLOBALS(fribidi)
#endif /* PHP_FRIBIDI_H */
-
/*
* Local variables:
* tab-width: 4