mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MFH:- Moved the old regex functions to own extension: ereg
This commit is contained in:
parent
3a5817e972
commit
aa3eee1dce
64 changed files with 228 additions and 222 deletions
17
configure.in
17
configure.in
|
@ -11,9 +11,9 @@ dnl ## Diversion 2 is the initial checking of OS features, programs,
|
|||
dnl ## libraries and so on.
|
||||
|
||||
dnl ## In diversion 3 we check for compile-time options to the PHP
|
||||
dnl ## core and how to deal with different system dependencies. This
|
||||
dnl ## includes what regex library is used and whether debugging or short
|
||||
dnl ## tags are enabled, and the default behaviour of php.ini options.
|
||||
dnl ## core and how to deal with different system dependencies.
|
||||
dnl ## This includes whether debugging or short tags are enabled
|
||||
dnl ## and the default behaviour of php.ini options.
|
||||
dnl ## This is also where an SAPI interface is selected (choosing between
|
||||
dnl ## Apache module, CGI etc.)
|
||||
|
||||
|
@ -270,10 +270,9 @@ fi
|
|||
divert(3)
|
||||
|
||||
dnl ## In diversion 3 we check for compile-time options to the PHP
|
||||
dnl ## core and how to deal with different system dependencies. This
|
||||
dnl ## includes what regex library is used and whether debugging or short
|
||||
dnl ## tags are enabled, and the default behaviour of php.ini options.
|
||||
|
||||
dnl ## core and how to deal with different system dependencies.
|
||||
dnl ## This includes whether debugging or short tags are enabled
|
||||
dnl ## and the default behaviour of php.ini options.
|
||||
|
||||
dnl Starting system checks.
|
||||
dnl -------------------------------------------------------------------------
|
||||
|
@ -518,7 +517,6 @@ putenv \
|
|||
realpath \
|
||||
random \
|
||||
rand_r \
|
||||
regcomp \
|
||||
res_search \
|
||||
scandir \
|
||||
setitimer \
|
||||
|
@ -1292,7 +1290,7 @@ esac
|
|||
PHP_SUBST(all_targets)
|
||||
PHP_SUBST(install_targets)
|
||||
|
||||
PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/ regex/])
|
||||
PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/])
|
||||
|
||||
PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c)
|
||||
|
||||
|
@ -1345,7 +1343,6 @@ fi
|
|||
PHP_ADD_SOURCES_X(Zend, zend_execute.c,,PHP_GLOBAL_OBJS,,$flag)
|
||||
|
||||
PHP_ADD_BUILD_DIR(main main/streams)
|
||||
PHP_ADD_BUILD_DIR(regex)
|
||||
PHP_ADD_BUILD_DIR(sapi/$PHP_SAPI sapi/cli)
|
||||
PHP_ADD_BUILD_DIR(TSRM)
|
||||
PHP_ADD_BUILD_DIR(Zend)
|
||||
|
|
2
ext/ereg/CREDITS
Normal file
2
ext/ereg/CREDITS
Normal file
|
@ -0,0 +1,2 @@
|
|||
ereg
|
||||
Rasmus Lerdorf, Jim Winstead, Jaakko Hyvätti
|
7
ext/ereg/config.w32
Normal file
7
ext/ereg/config.w32
Normal file
|
@ -0,0 +1,7 @@
|
|||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
EXTENSION("ereg", "ereg.c", false /* never shared */, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex");
|
||||
ADD_SOURCES("ext/ereg/regex", "regcomp.c regexec.c regerror.c regfree.c", "ereg");
|
||||
AC_DEFINE('REGEX', 1, 'Bundled regex');
|
||||
AC_DEFINE('HSREGEX', 1, 'Bundled regex');
|
56
ext/ereg/config0.m4
Normal file
56
ext/ereg/config0.m4
Normal file
|
@ -0,0 +1,56 @@
|
|||
dnl $Id$
|
||||
dnl config.m4 for extension ereg
|
||||
|
||||
dnl
|
||||
dnl Check for regex library type
|
||||
dnl
|
||||
PHP_ARG_WITH(regex,,
|
||||
[ --with-regex=TYPE regex library type: system, php. [TYPE=php]
|
||||
WARNING: Do NOT use unless you know what you are doing!], php, no)
|
||||
|
||||
case $PHP_REGEX in
|
||||
system)
|
||||
if test "$PHP_SAPI" = "apache" || test "$PHP_SAPI" = "apache2filter" || test "$PHP_SAPI" = "apache2handler"; then
|
||||
REGEX_TYPE=php
|
||||
else
|
||||
REGEX_TYPE=system
|
||||
fi
|
||||
;;
|
||||
yes | php)
|
||||
REGEX_TYPE=php
|
||||
;;
|
||||
*)
|
||||
REGEX_TYPE=php
|
||||
AC_MSG_WARN([Invalid regex library type selected. Using default value: php])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING([which regex library to use])
|
||||
AC_MSG_RESULT([$REGEX_TYPE])
|
||||
|
||||
if test "$REGEX_TYPE" = "php"; then
|
||||
ereg_regex_sources="regex/regcomp.c regex/regexec.c regex/regerror.c regex/regfree.c"
|
||||
ereg_regex_headers="regex/"
|
||||
PHP_EREG_CFLAGS="-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp"
|
||||
fi
|
||||
|
||||
PHP_NEW_EXTENSION(ereg, ereg.c $ereg_regex_sources, no,,$PHP_EREG_CFLAGS)
|
||||
PHP_INSTALL_HEADERS([ext/ereg], [php_ereg.h php_regex.h $ereg_regex_headers])
|
||||
|
||||
if test "$REGEX_TYPE" = "php"; then
|
||||
AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ])
|
||||
AC_DEFINE(HSREGEX,1,[ ])
|
||||
AC_DEFINE(REGEX,1,[ ])
|
||||
PHP_ADD_BUILD_DIR([$ext_builddir/regex], 1)
|
||||
PHP_ADD_INCLUDE([$ext_srcdir/regex])
|
||||
elif test "$REGEX_TYPE" = "system"; then
|
||||
AC_DEFINE(REGEX,0,[ ])
|
||||
dnl Check if field re_magic exists in struct regex_t
|
||||
AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <regex.h>], [regex_t rt; rt.re_magic;],
|
||||
[ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no])])
|
||||
if test "$ac_cv_regex_t_re_magic" = "yes"; then
|
||||
AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1)
|
||||
fi
|
||||
fi
|
|
@ -22,18 +22,96 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "php.h"
|
||||
#include "php_string.h"
|
||||
#include "reg.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
#include "php_ereg.h"
|
||||
#include "ext/standard/info.h"
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(reg)
|
||||
/* {{{ arginfo */
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ereg, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_eregi, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_ereg_replace, 0)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, replacement)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_eregi_replace, 0)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, replacement)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_split, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_spliti, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_sql_regcase, 0)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Function table */
|
||||
const zend_function_entry ereg_functions[] = {
|
||||
PHP_FE(ereg, arginfo_ereg)
|
||||
PHP_FE(ereg_replace, arginfo_ereg_replace)
|
||||
PHP_FE(eregi, arginfo_eregi)
|
||||
PHP_FE(eregi_replace, arginfo_eregi_replace)
|
||||
PHP_FE(split, arginfo_split)
|
||||
PHP_FE(spliti, arginfo_spliti)
|
||||
PHP_FE(sql_regcase, arginfo_sql_regcase)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ reg_cache */
|
||||
typedef struct {
|
||||
regex_t preg;
|
||||
int cflags;
|
||||
} reg_cache;
|
||||
|
||||
static int reg_magic = 0;
|
||||
/* }}} */
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(ereg)
|
||||
|
||||
/* {{{ Module entry */
|
||||
zend_module_entry ereg_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"ereg",
|
||||
ereg_functions,
|
||||
PHP_MINIT(ereg),
|
||||
PHP_MSHUTDOWN(ereg),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(ereg),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ _php_regcomp
|
||||
*/
|
||||
|
@ -44,7 +122,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
|||
reg_cache *rc = NULL;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if(zend_hash_find(®(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
|
||||
if(zend_hash_find(&EREG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
|
||||
&& rc->cflags == cflags) {
|
||||
#ifdef HAVE_REGEX_T_RE_MAGIC
|
||||
/*
|
||||
|
@ -52,7 +130,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
|||
* is, we flush it and compile the pattern from scratch.
|
||||
*/
|
||||
if (rc->preg.re_magic != reg_magic) {
|
||||
zend_hash_clean(®(ht_rc));
|
||||
zend_hash_clean(&EREG(ht_rc));
|
||||
} else {
|
||||
memcpy(preg, &rc->preg, sizeof(*preg));
|
||||
return r;
|
||||
|
@ -71,7 +149,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
|||
* it's good.
|
||||
*/
|
||||
if (!reg_magic) reg_magic = preg->re_magic;
|
||||
zend_hash_update(®(ht_rc), (char *) pattern, patlen+1,
|
||||
zend_hash_update(&EREG(ht_rc), (char *) pattern, patlen+1,
|
||||
(void *) &rcp, sizeof(rcp), NULL);
|
||||
}
|
||||
#else
|
||||
|
@ -83,7 +161,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
|||
|
||||
rcp.cflags = cflags;
|
||||
memcpy(&rcp.preg, preg, sizeof(*preg));
|
||||
zend_hash_update(®(ht_rc), (char *) pattern, patlen+1,
|
||||
zend_hash_update(&EREG(ht_rc), (char *) pattern, patlen+1,
|
||||
(void *) &rcp, sizeof(rcp), NULL);
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +170,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static void _free_reg_cache(reg_cache *rc)
|
||||
static void _free_ereg_cache(reg_cache *rc)
|
||||
{
|
||||
regfree(&rc->preg);
|
||||
}
|
||||
|
@ -102,45 +180,47 @@ static void _free_reg_cache(reg_cache *rc)
|
|||
#undef regcomp
|
||||
#define regcomp(a, b, c) _php_regcomp(a, b, c)
|
||||
|
||||
static void php_reg_init_globals(zend_reg_globals *reg_globals TSRMLS_DC)
|
||||
static void php_ereg_init_globals(zend_ereg_globals *ereg_globals TSRMLS_DC)
|
||||
{
|
||||
zend_hash_init(®_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
|
||||
zend_hash_init(&ereg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_ereg_cache, 1);
|
||||
}
|
||||
|
||||
static void php_reg_destroy_globals(zend_reg_globals *reg_globals TSRMLS_DC)
|
||||
static void php_ereg_destroy_globals(zend_ereg_globals *ereg_globals TSRMLS_DC)
|
||||
{
|
||||
zend_hash_destroy(®_globals->ht_rc);
|
||||
zend_hash_destroy(&ereg_globals->ht_rc);
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(regex)
|
||||
PHP_MINIT_FUNCTION(ereg)
|
||||
{
|
||||
ZEND_INIT_MODULE_GLOBALS(reg, php_reg_init_globals, php_reg_destroy_globals);
|
||||
ZEND_INIT_MODULE_GLOBALS(ereg, php_ereg_init_globals, php_ereg_destroy_globals);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(regex)
|
||||
PHP_MSHUTDOWN_FUNCTION(ereg)
|
||||
{
|
||||
#ifndef ZTS
|
||||
php_reg_destroy_globals(®_globals TSRMLS_CC);
|
||||
php_ereg_destroy_globals(&ereg_globals TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(regex)
|
||||
PHP_MINFO_FUNCTION(ereg)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
#if HSREGEX
|
||||
php_info_print_table_row(2, "Regex Library", "Bundled library enabled");
|
||||
#else
|
||||
php_info_print_table_row(2, "Regex Library", "System library enabled");
|
||||
#endif
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
|
||||
/* {{{ php_reg_eprint
|
||||
* php_reg_eprint - convert error number to name
|
||||
/* {{{ php_ereg_eprint
|
||||
* php_ereg_eprint - convert error number to name
|
||||
*/
|
||||
static void php_reg_eprint(int err, regex_t *re) {
|
||||
static void php_ereg_eprint(int err, regex_t *re) {
|
||||
char *buf = NULL, *message = NULL;
|
||||
size_t len;
|
||||
size_t buf_len;
|
||||
|
@ -221,7 +301,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
}
|
||||
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -235,7 +315,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
/* actually execute the regular expression */
|
||||
err = regexec(&re, string, re.re_nsub+1, subs, 0);
|
||||
if (err && err != REG_NOMATCH) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
regfree(&re);
|
||||
efree(subs);
|
||||
RETURN_FALSE;
|
||||
|
@ -292,9 +372,9 @@ PHP_FUNCTION(eregi)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_reg_replace
|
||||
/* {{{ php_ereg_replace
|
||||
* this is the meat and potatoes of regex replacement! */
|
||||
PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended)
|
||||
PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended)
|
||||
{
|
||||
regex_t re;
|
||||
regmatch_t *subs;
|
||||
|
@ -318,7 +398,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
|
|||
|
||||
err = regcomp(&re, pattern, copts);
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
return ((char *) -1);
|
||||
}
|
||||
|
||||
|
@ -337,7 +417,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
|
|||
err = regexec(&re, &string[pos], re.re_nsub+1, subs, (pos ? REG_NOTBOL : 0));
|
||||
|
||||
if (err && err != REG_NOMATCH) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
efree(subs);
|
||||
efree(buf);
|
||||
regfree(&re);
|
||||
|
@ -438,9 +518,9 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_ereg_replace
|
||||
/* {{{ php_do_ereg_replace
|
||||
*/
|
||||
static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
{
|
||||
zval **arg_pattern,
|
||||
**arg_replace,
|
||||
|
@ -486,7 +566,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
string = STR_EMPTY_ALLOC();
|
||||
|
||||
/* do the actual work */
|
||||
ret = php_reg_replace(pattern, replace, string, icase, 1);
|
||||
ret = php_ereg_replace(pattern, replace, string, icase, 1);
|
||||
if (ret == (char *) -1) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
|
@ -504,7 +584,7 @@ static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
Replace regular expression */
|
||||
PHP_FUNCTION(ereg_replace)
|
||||
{
|
||||
php_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
php_do_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -512,7 +592,7 @@ PHP_FUNCTION(ereg_replace)
|
|||
Case insensitive replace regular expression */
|
||||
PHP_FUNCTION(eregi_replace)
|
||||
{
|
||||
php_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
php_do_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -548,7 +628,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
|
||||
err = regcomp(&re, Z_STRVAL_PP(spliton), REG_EXTENDED | copts);
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
@ -590,7 +670,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
|||
|
||||
/* see if we encountered an error */
|
||||
if (err && err != REG_NOMATCH) {
|
||||
php_reg_eprint(err, &re);
|
||||
php_ereg_eprint(err, &re);
|
||||
regfree(&re);
|
||||
zend_hash_destroy(Z_ARRVAL_P(return_value));
|
||||
efree(Z_ARRVAL_P(return_value));
|
|
@ -19,10 +19,15 @@
|
|||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef REG_H
|
||||
#define REG_H
|
||||
#ifndef EREG_H
|
||||
#define EREG_H
|
||||
|
||||
PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended);
|
||||
#include "php_regex.h"
|
||||
|
||||
extern zend_module_entry ereg_module_entry;
|
||||
#define phpext_ereg_ptr &ereg_module_entry
|
||||
|
||||
PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended);
|
||||
|
||||
PHP_FUNCTION(ereg);
|
||||
PHP_FUNCTION(eregi);
|
||||
|
@ -32,19 +37,19 @@ PHP_FUNCTION(split);
|
|||
PHP_FUNCTION(spliti);
|
||||
PHPAPI PHP_FUNCTION(sql_regcase);
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(reg)
|
||||
ZEND_BEGIN_MODULE_GLOBALS(ereg)
|
||||
HashTable ht_rc;
|
||||
ZEND_END_MODULE_GLOBALS(reg)
|
||||
|
||||
PHP_MINIT_FUNCTION(regex);
|
||||
PHP_MSHUTDOWN_FUNCTION(regex);
|
||||
PHP_MINFO_FUNCTION(regex);
|
||||
ZEND_END_MODULE_GLOBALS(ereg)
|
||||
|
||||
/* Module functions */
|
||||
PHP_MINIT_FUNCTION(ereg);
|
||||
PHP_MSHUTDOWN_FUNCTION(ereg);
|
||||
PHP_MINFO_FUNCTION(ereg);
|
||||
|
||||
#ifdef ZTS
|
||||
#define REG(v) TSRMG(reg_globals_id, zend_reg_globals *, v)
|
||||
#define EREG(v) TSRMG(ereg_globals_id, zend_ereg_globals *, v)
|
||||
#else
|
||||
#define REG(v) (reg_globals.v)
|
||||
#define EREG(v) (ereg_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* REG_H */
|
|
@ -27,15 +27,14 @@
|
|||
* 1.. bundled regex
|
||||
*/
|
||||
|
||||
#if REGEX
|
||||
/* get aliases */
|
||||
#include "regex/regex_extra.h"
|
||||
#include "regex/regex.h"
|
||||
#if (REGEX == 1)
|
||||
/* Define aliases */
|
||||
#define regexec php_regexec
|
||||
#define regerror php_regerror
|
||||
#define regfree php_regfree
|
||||
#define regcomp php_regcomp
|
||||
|
||||
/* get rid of aliases */
|
||||
#define PHP_NO_ALIASES
|
||||
#include "regex/regex_extra.h"
|
||||
#undef PHP_NO_ALIASES
|
||||
#include "ext/ereg/regex/regex.h"
|
||||
|
||||
#undef _PCREPOSIX_H
|
||||
#define _PCREPOSIX_H 1
|
||||
|
@ -55,6 +54,7 @@
|
|||
#ifndef _H_REGEX
|
||||
#define _H_REGEX 1 /* This one is for AIX */
|
||||
#endif
|
||||
|
||||
#elif REGEX == 0
|
||||
#include <regex.h>
|
||||
#ifndef _REGEX_H_
|
|
@ -1,7 +1,5 @@
|
|||
/* utility definitions */
|
||||
|
||||
#include "regex_extra.h"
|
||||
|
||||
#ifdef _POSIX2_RE_DUP_MAX
|
||||
#define DUPMAX _POSIX2_RE_DUP_MAX
|
||||
#else
|
|
@ -36,6 +36,7 @@
|
|||
#include "php_ini.h"
|
||||
#include "ext/standard/php_standard.h"
|
||||
#include "ext/standard/php_smart_str.h"
|
||||
#include "ext/ereg/php_regex.h"
|
||||
|
||||
#undef PACKAGE_BUGREPORT
|
||||
#undef PACKAGE_NAME
|
||||
|
|
|
@ -2203,54 +2203,6 @@ static
|
|||
ZEND_BEGIN_ARG_INFO(arginfo_mt_getrandmax, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
/* {{{ reg.c */
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ereg, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_eregi, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_ereg_replace, 0)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, replacement)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_eregi_replace, 0)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, replacement)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_split, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_spliti, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_sql_regcase, 0)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
/* {{{ sha1.c */
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_sha1, 0, 0, 1)
|
||||
|
@ -3202,6 +3154,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
|
|||
PHP_FE(similar_text, arginfo_similar_text)
|
||||
PHP_FE(explode, arginfo_explode)
|
||||
PHP_FE(implode, arginfo_implode)
|
||||
PHP_FALIAS(join, implode, arginfo_implode)
|
||||
PHP_FE(setlocale, arginfo_setlocale)
|
||||
PHP_FE(localeconv, arginfo_localeconv)
|
||||
|
||||
|
@ -3478,16 +3431,6 @@ const zend_function_entry basic_functions[] = { /* {{{ */
|
|||
PHP_FE(is_scalar, arginfo_is_scalar)
|
||||
PHP_FE(is_callable, arginfo_is_callable)
|
||||
|
||||
/* functions from reg.c */
|
||||
PHP_FE(ereg, arginfo_ereg)
|
||||
PHP_FE(ereg_replace, arginfo_ereg_replace)
|
||||
PHP_FE(eregi, arginfo_eregi)
|
||||
PHP_FE(eregi_replace, arginfo_eregi_replace)
|
||||
PHP_FE(split, arginfo_split)
|
||||
PHP_FE(spliti, arginfo_spliti)
|
||||
PHP_FALIAS(join, implode, arginfo_implode)
|
||||
PHP_FE(sql_regcase, arginfo_sql_regcase)
|
||||
|
||||
/* functions from dl.c */
|
||||
PHP_FE(dl, arginfo_dl)
|
||||
|
||||
|
@ -4043,7 +3986,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
|
|||
register_html_constants(INIT_FUNC_ARGS_PASSTHRU);
|
||||
register_string_constants(INIT_FUNC_ARGS_PASSTHRU);
|
||||
|
||||
PHP_MINIT(regex)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MINIT(file)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MINIT(pack)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MINIT(browscap)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
|
@ -4121,7 +4063,6 @@ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */
|
|||
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
|
||||
PHP_MSHUTDOWN(regex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MSHUTDOWN(array)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
|
@ -4234,7 +4175,6 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
|
|||
PHP_MINFO_FUNCTION(basic) /* {{{ */
|
||||
{
|
||||
php_info_print_table_start();
|
||||
PHP_MINFO(regex)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MINFO(dl)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
|
||||
PHP_MINFO(mail)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
|
||||
php_info_print_table_end();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
/* $Id$ */
|
||||
|
||||
#include "php.h"
|
||||
#include "php_regex.h"
|
||||
#include "ext/ereg/php_regex.h"
|
||||
#include "php_browscap.h"
|
||||
#include "php_ini.h"
|
||||
#include "php_string.h"
|
||||
|
|
|
@ -207,52 +207,6 @@ AC_FUNC_FNMATCH
|
|||
|
||||
divert(5)dnl
|
||||
|
||||
dnl
|
||||
dnl Check for regex library type
|
||||
dnl
|
||||
PHP_ARG_WITH(regex,,
|
||||
[ --with-regex=TYPE regex library type: system, apache, php. [TYPE=php]
|
||||
WARNING: Do NOT use unless you know what you are doing!], php, no)
|
||||
|
||||
case $PHP_REGEX in
|
||||
system)
|
||||
if test "$PHP_SAPI" = "apache" || test "$PHP_SAPI" = "apache2filter" || test "$PHP_SAPI" = "apache2handler"; then
|
||||
REGEX_TYPE=php
|
||||
else
|
||||
REGEX_TYPE=system
|
||||
fi
|
||||
;;
|
||||
apache)
|
||||
REGEX_TYPE=apache
|
||||
;;
|
||||
php)
|
||||
REGEX_TYPE=php
|
||||
;;
|
||||
*)
|
||||
REGEX_TYPE=php
|
||||
AC_MSG_WARN(Invalid regex library type selected. Using default value: php)
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$REGEX_TYPE" = "php"; then
|
||||
AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ])
|
||||
AC_DEFINE(HSREGEX,1,[ ])
|
||||
AC_DEFINE(REGEX,1,[ ])
|
||||
PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c)
|
||||
elif test "$REGEX_TYPE" = "system"; then
|
||||
AC_DEFINE(REGEX,0,[ ])
|
||||
dnl Check if field re_magic exists in struct regex_t
|
||||
AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <regex.h>], [regex_t rt; rt.re_magic;],
|
||||
[ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no])])
|
||||
if test "$ac_cv_regex_t_re_magic" = "yes"; then
|
||||
AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1)
|
||||
fi
|
||||
fi
|
||||
AC_MSG_CHECKING([which regex library to use])
|
||||
AC_MSG_RESULT([$REGEX_TYPE])
|
||||
|
||||
dnl
|
||||
dnl round fuzz
|
||||
dnl
|
||||
|
@ -502,7 +456,7 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.
|
|||
flock_compat.c formatted_print.c fsock.c head.c html.c image.c \
|
||||
info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c \
|
||||
microtime.c pack.c pageinfo.c quot_print.c rand.c \
|
||||
reg.c soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \
|
||||
soundex.c string.c scanf.c syslog.c type.c uniqid.c url.c \
|
||||
url_scanner.c var.c versioning.c assert.c strnatcmp.c levenshtein.c \
|
||||
incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
|
||||
http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
|
||||
|
|
|
@ -10,7 +10,7 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \
|
|||
crc32.c crypt.c cyr_convert.c datetime.c dir.c dl.c dns.c exec.c \
|
||||
file.c filestat.c formatted_print.c fsock.c head.c html.c image.c \
|
||||
info.c iptc.c lcg.c link.c mail.c math.c md5.c metaphone.c microtime.c \
|
||||
pack.c pageinfo.c quot_print.c rand.c reg.c soundex.c \
|
||||
pack.c pageinfo.c quot_print.c rand.c soundex.c \
|
||||
string.c scanf.c syslog.c type.c uniqid.c url.c url_scanner.c var.c \
|
||||
versioning.c assert.c strnatcmp.c levenshtein.c incomplete_class.c \
|
||||
url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#else
|
||||
#include <php_config.h>
|
||||
#endif
|
||||
#include "reg.h"
|
||||
#include "html.h"
|
||||
#include "php_string.h"
|
||||
#include "SAPI.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "base64.h"
|
||||
#include "php_dir.h"
|
||||
#include "dns.h"
|
||||
#include "reg.h"
|
||||
#include "php_mail.h"
|
||||
#include "md5.h"
|
||||
#include "sha1.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "php.h"
|
||||
#include "reg.h"
|
||||
#include "php_rand.h"
|
||||
#include "php_string.h"
|
||||
#include "php_variables.h"
|
||||
|
|
|
@ -71,8 +71,6 @@
|
|||
#define PHP_OS PHP_UNAME
|
||||
#endif
|
||||
|
||||
#include "php_regex.h"
|
||||
|
||||
#if HAVE_ASSERT_H
|
||||
#if PHP_DEBUG
|
||||
#undef NDEBUG
|
||||
|
@ -193,10 +191,6 @@ typedef unsigned int socklen_t;
|
|||
char *strerror(int);
|
||||
#endif
|
||||
|
||||
#if (REGEX == 1 || REGEX == 0) && !defined(NO_REGEX_EXTRA_H)
|
||||
#include "regex/regex_extra.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_PWD_H
|
||||
# ifdef PHP_WIN32
|
||||
#include "win32/param.h"
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/* do not frame this - we must be able to include this file multiple times */
|
||||
|
||||
#undef regexec
|
||||
#undef regerror
|
||||
#undef regfree
|
||||
#undef regcomp
|
||||
|
||||
#if (defined(REGEX) && REGEX == 1) || (!defined(REGEX))
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
|
||||
#ifndef PHP_NO_ALIASES
|
||||
|
||||
#define regexec php_regexec
|
||||
#define regerror php_regerror
|
||||
#define regfree php_regfree
|
||||
#define regcomp php_regcomp
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -31,7 +31,7 @@
|
|||
#endif
|
||||
|
||||
#include "zend.h"
|
||||
#include "php_regex.h"
|
||||
#include "ext/ereg/php_regex.h"
|
||||
#include "php_compat.h"
|
||||
|
||||
#ifdef HAVE_OPENSSL_EXT
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "zend.h"
|
||||
#include "zend_stack.h"
|
||||
#include "php_regex.h"
|
||||
#include "ext/ereg/php_regex.h"
|
||||
|
||||
#include "httpd.h"
|
||||
#include "http_config.h"
|
||||
|
|
|
@ -99,7 +99,7 @@ if (PHP_PREFIX == '') {
|
|||
}
|
||||
DEFINE('PHP_PREFIX', PHP_PREFIX);
|
||||
|
||||
DEFINE("BASE_INCLUDES", "/I . /I main /I regex /I Zend /I TSRM /I ext ");
|
||||
DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");
|
||||
|
||||
// CFLAGS for building the PHP dll
|
||||
DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS \
|
||||
|
@ -312,8 +312,6 @@ ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c
|
|||
ADD_SOURCES("win32", "crypt_win32.c glob.c md5crypt.c readdir.c \
|
||||
registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c globals.c");
|
||||
|
||||
ADD_SOURCES("regex", "regcomp.c regerror.c regexec.c regfree.c");
|
||||
|
||||
STDOUT.WriteBlankLines(1);
|
||||
|
||||
/* Can we build with IPv6 support? */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue