mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 10:25:41 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af171ecae8 |
No files matched your search
@@ -1,92 +1,27 @@
|
||||
PHP 4 NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
20 Dec 2007, Version 4.4.8RC1
|
||||
- Improved fix for MOPB-02-2007. (Ilia)
|
||||
- Fixed an integer overflow inside chunk_split(). Identified by Gerhard Wagner.
|
||||
(Ilia)
|
||||
- Fixed integer overlow in str[c]spn(). (Stas)
|
||||
- Fixed regression in glob when open_basedir is on introduced by #41655 fix
|
||||
(Pierre)
|
||||
- Fixed money_format() not to accept multiple %i or %n tokens. (Stas, Ilia)
|
||||
- Addded "max_input_nesting_level" php.ini option to limit nesting level of
|
||||
input variables. Fix for MOPB-03-2007. (Stas)
|
||||
- Fixed INFILE LOCAL option handling with MySQL - now not allowed when
|
||||
open_basedir or safe_mode is active (Stas)
|
||||
- Fixed session.save_path and error_log values to be checked against
|
||||
open_basedir and safe_mode (CVE-2007-3378) (Stas, Maksymilian Arciemowicz)
|
||||
- Fixed bug #43010 (Fixed regression in imagearc with two equivelent angles)
|
||||
(Pierre)
|
||||
- Fixed bug #41765 (Recode crashes/does not work on amd64)
|
||||
(nexus at smoula dot net, Stas)
|
||||
- Fixed bug #41630 (segfault when an invalid color index is present in
|
||||
the image data). (Reported by Elliot <wccoder@gmail dot com>) (Pierre)
|
||||
- Fixed bug #41628 (PHP settings leak between Virtual Hosts in
|
||||
Apache 1.3). (Scott, manuel at mausz dot at)
|
||||
- Fixed bug #38798 (OpenSSL init corrected in php5 but not in php4). (Tony)
|
||||
|
||||
04 May 2007, Version 4.4.7
|
||||
- Fixed libgd #86 (Fixed possible infinite loop in imagecreatefrompng)
|
||||
(Reported by Xavier Roche) (Pierre)
|
||||
- Fixed MOPB-33-2007 (PHP mail() Message ASCIIZ Byte Truncation). (Ilia)
|
||||
- Fixed MOPB-32-2007 (Double free inside session_decode()). (Ilia)
|
||||
- Fixed MOPB-26-2007 (mb_parse_str() can be used to activate
|
||||
register_globals). (Ilia)
|
||||
- Fixed MOPB-24-2007 (Fixed unallocated memory access/double free in in
|
||||
array_user_key_compare()). (Stas)
|
||||
- Fixed MOPB-22-2007 (PHP session_regenerate_id() Double Free Vulnerability).
|
||||
(Ilia)
|
||||
- Fixed MOPB-21-2007 (An open_basedir/safe_mode bypass inside the
|
||||
compress.bzip2 wraper). (Ilia)
|
||||
- Fixed MOPB-8-2007 (XSS in phpinfo()). (Joe Orton, Stas)
|
||||
- Fixed CVE-2007-1001 (GD wbmp used with invalid image size). (Pierre)
|
||||
- Fixed CVE-2007-0455 (Buffer overflow in gdImageStringFTEx, used by imagettf
|
||||
function). (Kees Cook, Pierre)
|
||||
- Fixed bug #41655 (open_basedir bypass via glob()). (Ilia)
|
||||
- Fixed bug #41527 (WDDX deserialize numeric string array key). (Matt, Ilia)
|
||||
- Fixed bug #41252 (Calling mcrypt_generic without first calling
|
||||
mcrypt_generic_init crashes). (Derick)
|
||||
- Fixed bug #40998 (long session array keys are truncated). (Tony)
|
||||
- Fixed bug #40915 (addcslashes unexpected behavior with binary input). (Tony)
|
||||
- Fixed bug #40831 (cURL extension doesn't clean up the buffer of reused
|
||||
handle). (Tony)
|
||||
- Fixed bug #40747 (possible crash in session when save_path is out of
|
||||
open_basedir). (Tony)
|
||||
- Fixed bug #38236 (Binary data gets corrupted on multipart/formdata POST)
|
||||
(patch by ass3mbler@gmail.com)
|
||||
- Fixed huge CPU usage in imagearc when used with large angles (libgd bug #74).
|
||||
(Pierre)
|
||||
- Fixed CRLF injection inside ftp_putcmd(). (Ilia)
|
||||
|
||||
28 Feb 2007, Version 4.4.6
|
||||
- Updated PCRE to version 7.0. (Nuno)
|
||||
- Fixed segfault in ext/session when register_globals=On. (Tony)
|
||||
- Fixed bug #40635 (segfault in cURL extension). (Tony)
|
||||
- Fixed bug #40611 (possible cURL memory error). (Tony)
|
||||
- Fixed bug #40578 (imagettftext() multithreading issue). (Tony)
|
||||
- Fixed bug #40502 (ext/interbase compile failure). (Tony)
|
||||
- Fixed bug #40286 (PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when
|
||||
parent is killed). (Dmitry)
|
||||
|
||||
14 Feb 2007, Version 4.4.5
|
||||
- Upgraded PEAR to 1.5.0. (Greg)
|
||||
- Updated PCRE to version 6.7. (Ilia)
|
||||
- Moved extensions to PECL:
|
||||
. ext/ovrimos (Derick)
|
||||
|
||||
- Added a meta tag to phpinfo() output to prevent search engines from
|
||||
indexing the page. (Ilia)
|
||||
01 Feb 2007, Version 4.4.5RC2
|
||||
- Fixed bug #39819 (Using $this not in object context can cause segfaults).
|
||||
(Dmitry)
|
||||
- Fixed bug #36248 (CURLOPT_HEADERFUNCTION, couldn't set the function in the
|
||||
class). (Ilia)
|
||||
- Backported a fix in the configure tests to detect the "rounding fuzz".
|
||||
(Derick, Joe Orton)
|
||||
- Backported fix for ext/imap compilation failure with recent c-client
|
||||
versions. (Tony)
|
||||
- Upgraded PEAR to 1.5.0. (Greg)
|
||||
- Moved extensions to PECL:
|
||||
. ext/ovrimos (Derick)
|
||||
|
||||
04 Jan 2007, Version 4.4.5RC1
|
||||
- Added a meta tag to phpinfo() output to prevent search engines from
|
||||
indexing the page. (Ilia)
|
||||
- Updated PCRE to version 6.7. (Ilia)
|
||||
- Fixed missing open_basedir check inside chdir() function. (Ilia)
|
||||
- Fixed bug #40335 (Compile fails when using GCC 4.1.1/binutils 2.17). (Tony)
|
||||
- Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for
|
||||
timestamp fields). (Ilia)
|
||||
- Fixed bug #39890 (using autoconf 2.6x and --with-layout=GNU breaks PEAR
|
||||
install path). (Tony)
|
||||
- Fixed bug #39819 (Using $this not in object context can cause segfaults).
|
||||
(Dmitry)
|
||||
- Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4
|
||||
support is enabled). (Tony)
|
||||
- Fixed bug #39583 (ftp_put() does not change transfer mode to ASCII). (Tony)
|
||||
@@ -110,8 +45,6 @@ PHP 4 NEWS
|
||||
- Fixed bug #37812 (aggregate_methods_by_list fails to take certain methods).
|
||||
(Hannes)
|
||||
- Fixed bug #36975 (natcasesort() causes array_pop() to misbehave). (Hannes)
|
||||
- Fixed bug #36248 (CURLOPT_HEADERFUNCTION, couldn't set the function in the
|
||||
class). (Ilia)
|
||||
- Fixed bug #34066 (recursive array_walk causes segfault). (Tony)
|
||||
|
||||
17 Aug 2006, Version 4.4.4
|
||||
|
||||
+3
-6
@@ -39,7 +39,8 @@ HEAD Will become PHP 6.0. This CVS branch is for active development.
|
||||
PHP_5_2 Is used to release the PHP 5.2.x series. Only minor feature
|
||||
enhancements may go in here, but please keep that as infrequent as
|
||||
possible.
|
||||
PHP_5_1 This branch is closed.
|
||||
PHP_5_1 Is used to release the PHP 5.1.x series. Only bugfixes are permitted
|
||||
on this branch (Consult the releasemaster prior to commit).
|
||||
PHP_4_4 Is used to release the PHP 4.4.x series. Only bugfixes are permitted
|
||||
on this branch (Consult the releasemaster prior to commit).
|
||||
PHP_4_3 This branch is closed.
|
||||
@@ -98,13 +99,9 @@ For string.c:
|
||||
|
||||
The # lines will be omitted from the ChangeLog automagically.
|
||||
|
||||
Use the [DOC] tag in your log message whenever you feel that your changes
|
||||
imply a documentation modification. The php-doc team will automatically
|
||||
get notified about your commit through the php-doc mailing list.
|
||||
|
||||
If you fix some bugs, you should note the bug ID numbers in your
|
||||
commit message. Bug ID should be prefixed by "#" for easier access to
|
||||
bug report when developers are browsing CVS via LXR or Bonsai.
|
||||
bug report when developers are browsing CVS via. LXR or Bonsai.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
|
||||
ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
|
||||
ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
|
||||
ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
|
||||
test -f "$src" && sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
|
||||
sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
|
||||
])
|
||||
|
||||
AC_DEFUN([PHP_PROG_RE2C],[
|
||||
|
||||
+19
-615
@@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
##
|
||||
## GNU shtool -- The GNU Portable Shell Tool
|
||||
## Copyright (c) 1994-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
## See http://www.gnu.org/software/shtool/ for more information.
|
||||
## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
|
||||
##
|
||||
## Version: 2.0.6 (19-Apr-2006)
|
||||
## Contents: 5/19 available modules
|
||||
## Version: 2.0.2 (15-Jun-2005)
|
||||
## Contents: 4/19 available modules
|
||||
##
|
||||
|
||||
##
|
||||
@@ -41,7 +41,6 @@
|
||||
## echo Print string with optional construct expansion
|
||||
## install Install a program, script or datafile
|
||||
## mkdir Make one or more directories
|
||||
## platform Platform Identification Utility
|
||||
## path Deal with program paths
|
||||
##
|
||||
## Not available commands (because module was not built-in):
|
||||
@@ -55,48 +54,24 @@
|
||||
## rotate Logfile rotation
|
||||
## tarball Roll distribution tarballs
|
||||
## subst Apply sed(1) substitution operations
|
||||
## platform Platform Identification Utility
|
||||
## arx Extended archive command
|
||||
## slo Separate linker options by library class
|
||||
## scpp Sharing C Pre-Processor
|
||||
## version Maintain a version information file
|
||||
##
|
||||
|
||||
# maximum Bourne-Shell compatibility
|
||||
if [ ".$ZSH_VERSION" != . ] && (emulate sh) >/dev/null 2>&1; then
|
||||
# reconfigure zsh(1)
|
||||
emulate sh
|
||||
NULLCMD=:
|
||||
alias -g '${1+"$@"}'='"$@"'
|
||||
elif [ ".$BASH_VERSION" != . ] && (set -o posix) >/dev/null 2>&1; then
|
||||
# reconfigure bash(1)
|
||||
set -o posix
|
||||
fi
|
||||
|
||||
# maximum independence of NLS nuisances
|
||||
for var in \
|
||||
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
|
||||
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
|
||||
LC_TELEPHONE LC_TIME
|
||||
do
|
||||
if (set +x; test -z "`(eval $var=C; export $var) 2>&1`"); then
|
||||
eval $var=C; export $var
|
||||
else
|
||||
unset $var
|
||||
fi
|
||||
done
|
||||
|
||||
# initial command line handling
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "$0:Error: invalid command line" 1>&2
|
||||
echo "$0:Hint: run \`$0 -h' for usage" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
|
||||
echo "This is GNU shtool, version 2.0.6 (19-Apr-2006)"
|
||||
echo 'Copyright (c) 1994-2006 Ralf S. Engelschall <rse@engelschall.com>'
|
||||
echo 'Report bugs to <bug-shtool@gnu.org>'
|
||||
echo "This is GNU shtool, version 2.0.2 (15-Jun-2005)"
|
||||
echo "Copyright (c) 1994-2005 Ralf S. Engelschall <rse@engelschall.com>"
|
||||
echo "Report bugs to <bug-shtool@gnu.org>"
|
||||
echo ''
|
||||
echo 'Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]'
|
||||
echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
|
||||
echo ''
|
||||
echo 'Available global <options>:'
|
||||
echo ' -v, --version display shtool version information'
|
||||
@@ -113,10 +88,6 @@ if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
|
||||
echo ' mkdir [-t|--trace] [-f|--force] [-p|--parents] [-m|--mode'
|
||||
echo ' <mode>] [-o|--owner <owner>] [-g|--group <group>] <dir>'
|
||||
echo ' [<dir> ...]'
|
||||
echo ' platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc'
|
||||
echo ' <string>] [-L|--lower] [-U|--upper] [-v|--verbose]'
|
||||
echo ' [-c|--concise] [-n|--no-newline] [-t|--type <type>]'
|
||||
echo ' [-V|--version] [-h|--help]'
|
||||
echo ' path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename]'
|
||||
echo ' [-m|--magic] [-p|--path <path>] <str> [<str> ...]'
|
||||
echo ''
|
||||
@@ -146,6 +117,10 @@ if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
|
||||
echo ' [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup'
|
||||
echo ' <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>]'
|
||||
echo ' [...]'
|
||||
echo ' platform [-F|--format <format>] [-S|--sep <string>] [-C|--conc'
|
||||
echo ' <string>] [-L|--lower] [-U|--upper] [-v|--verbose]'
|
||||
echo ' [-c|--concise] [-n|--no-newline] [-t|--type <type>]'
|
||||
echo ' [-V|--version] [-h|--help]'
|
||||
echo ' arx [-t|--trace] [-C|--command <cmd>] <op> <archive> [<file>'
|
||||
echo ' ...]'
|
||||
echo ' slo [-p|--prefix <str>] -- -L<dir> -l<lib> [-L<dir> -l<lib>'
|
||||
@@ -161,11 +136,11 @@ if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then
|
||||
echo "GNU shtool 2.0.6 (19-Apr-2006)"
|
||||
echo "GNU shtool 2.0.2 (15-Jun-2005)"
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then
|
||||
shtoolize -oshtool echo install mkdir platform path
|
||||
shtoolize -oshtool echo install mkdir path
|
||||
exit 0
|
||||
fi
|
||||
if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then
|
||||
@@ -174,7 +149,7 @@ if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then
|
||||
fi
|
||||
name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
|
||||
case "$name" in
|
||||
echo|install|mkdir|platform|path )
|
||||
echo|install|mkdir|path )
|
||||
# implicit tool command selection
|
||||
tool="$name"
|
||||
;;
|
||||
@@ -232,24 +207,6 @@ case $tool in
|
||||
opt_o=""
|
||||
opt_g=""
|
||||
;;
|
||||
platform )
|
||||
str_tool="platform"
|
||||
str_usage="[-F|--format <format>] [-S|--sep <string>] [-C|--conc <string>] [-L|--lower] [-U|--upper] [-v|--verbose] [-c|--concise] [-n|--no-newline] [-t|--type <type>] [-V|--version] [-h|--help]"
|
||||
arg_spec="0="
|
||||
opt_spec="F:S:C:L.U.v.c.n.t:d.V.h."
|
||||
opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,v:verbose,c:consise,t:type,n:no-newline,V:version,h:help"
|
||||
opt_F="%{sp} (%{ap})"
|
||||
opt_S=" "
|
||||
opt_C="/"
|
||||
opt_L=no
|
||||
opt_U=no
|
||||
opt_t=""
|
||||
opt_v=no
|
||||
opt_c=no
|
||||
opt_n=no
|
||||
opt_V=no
|
||||
opt_h=no
|
||||
;;
|
||||
path )
|
||||
str_tool="path"
|
||||
str_usage="[-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path <path>] <str> [<str> ...]"
|
||||
@@ -473,7 +430,7 @@ case $tool in
|
||||
echo )
|
||||
##
|
||||
## echo -- Print string with optional construct expansion
|
||||
## Copyright (c) 1998-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
|
||||
text="$*"
|
||||
@@ -771,7 +728,7 @@ echo )
|
||||
install )
|
||||
##
|
||||
## install -- Install a program, script or datafile
|
||||
## Copyright (c) 1997-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1997-2005 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
|
||||
# special case: "shtool install -d <dir> [...]" internally
|
||||
@@ -934,7 +891,7 @@ install )
|
||||
mkdir )
|
||||
##
|
||||
## mkdir -- Make one or more directories
|
||||
## Copyright (c) 1996-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1996-2005 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
|
||||
errstatus=0
|
||||
@@ -1019,563 +976,10 @@ mkdir )
|
||||
shtool_exit $errstatus
|
||||
;;
|
||||
|
||||
platform )
|
||||
##
|
||||
## platform -- Platform Identification Utility
|
||||
## Copyright (c) 2003-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
|
||||
# option post-processing
|
||||
if [ ".$opt_t" != . ]; then
|
||||
case "$opt_t" in
|
||||
binary )
|
||||
# binary package id (OpenPKG RPM)
|
||||
opt_F="%<ap>-%<sp>"
|
||||
opt_L=yes
|
||||
opt_S=""
|
||||
opt_C="+"
|
||||
;;
|
||||
build )
|
||||
# build time checking (OpenPKG RPM)
|
||||
opt_F="%<at>-%<st>"
|
||||
opt_L=yes
|
||||
opt_S=""
|
||||
opt_C="+"
|
||||
;;
|
||||
gnu )
|
||||
# GNU config.guess style <arch>-<vendor>-<os><osversion>
|
||||
opt_F="%<at>-unknown-%<st>"
|
||||
opt_L=yes
|
||||
opt_S=""
|
||||
opt_C="+"
|
||||
;;
|
||||
web )
|
||||
# non-whitespace HTTP Server-header id
|
||||
opt_F="%<sp>-%<ap>"
|
||||
opt_S="/"
|
||||
opt_C="+"
|
||||
;;
|
||||
summary)
|
||||
# human readable verbose summary information
|
||||
opt_F="Class: %[sc] (%[ac])\\nProduct: %[sp] (%[ap])\\nTechnology: %[st] (%[at])"
|
||||
opt_S=" "
|
||||
opt_C="/"
|
||||
;;
|
||||
all-in-one )
|
||||
# full-table all-in-one information
|
||||
opt_F=""
|
||||
opt_F="${opt_F}concise architecture class: %<ac>\\n"
|
||||
opt_F="${opt_F}regular architecture class: %{ac}\\n"
|
||||
opt_F="${opt_F}verbose architecture class: %[ac]\\n"
|
||||
opt_F="${opt_F}concise architecture product: %<ap>\\n"
|
||||
opt_F="${opt_F}regular architecture product: %{ap}\\n"
|
||||
opt_F="${opt_F}verbose architecture product: %[ap]\\n"
|
||||
opt_F="${opt_F}concise architecture technology: %<at>\\n"
|
||||
opt_F="${opt_F}regular architecture technology: %{at}\\n"
|
||||
opt_F="${opt_F}verbose architecture technology: %[at]\\n"
|
||||
opt_F="${opt_F}concise system class: %<sc>\\n"
|
||||
opt_F="${opt_F}regular system class: %{sc}\\n"
|
||||
opt_F="${opt_F}verbose system class: %[sc]\\n"
|
||||
opt_F="${opt_F}concise system product: %<sp>\\n"
|
||||
opt_F="${opt_F}regular system product: %{sp}\\n"
|
||||
opt_F="${opt_F}verbose system product: %[sp]\\n"
|
||||
opt_F="${opt_F}concise system technology: %<st>\\n"
|
||||
opt_F="${opt_F}regular system technology: %{st}\\n"
|
||||
opt_F="${opt_F}verbose system technology: %[st]"
|
||||
;;
|
||||
* )
|
||||
echo "$msgprefix:Error: invalid type \`$opt_t'" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# assemble initial platform information
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` ||\
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null` ||\
|
||||
UNAME_MACHINE='unknown'
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` ||\
|
||||
UNAME_SYSTEM='unknown'
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` ||\
|
||||
UNAME_RELEASE=`(uname -v) 2>/dev/null` ||\
|
||||
UNAME_RELEASE='unknown'
|
||||
|
||||
UNAME="${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}"
|
||||
|
||||
AC=""; AP=""; AT=""
|
||||
SC=""; SP=""; ST=""
|
||||
|
||||
# dispatch into platform specific sections
|
||||
case "${UNAME}" in
|
||||
|
||||
# FreeBSD
|
||||
*:FreeBSD:* )
|
||||
# determine architecture
|
||||
AC="${UNAME_MACHINE}"
|
||||
case "${AC}" in
|
||||
i386 ) AC="iX86" ;;
|
||||
esac
|
||||
AP="${AC}"
|
||||
AT="${AP}"
|
||||
if [ ".${AT}" = ".iX86" ]; then
|
||||
case "`(/sbin/sysctl -n hw.model) 2>&1`" in
|
||||
*"Xeon"* | *"Pentium Pro"* | *"Cyrix 6x86MX"* | *"Pentium II"* | *"Pentium III"* | *"Pentium 4"* | *"Celeron"* ) AT="i686" ;;
|
||||
*"Pentium"* ) AT="i586" ;; *"i486[SD]X"* | *"Cyrix 486"* | *"Cyrix [56]x86"* | *"Blue Lightning" | *"Cyrix 486S/DX" ) AT="i486" ;;
|
||||
*"i386[SD]X"* | *"NexGen 586"* ) AT="i386" ;;
|
||||
esac
|
||||
fi
|
||||
# determine system
|
||||
r=`echo "${UNAME_RELEASE}" |\
|
||||
sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/'`
|
||||
ST="FreeBSD ${r}"
|
||||
SP="${ST}"
|
||||
case "${r}" in
|
||||
1.* ) SC="4.3BSD" ;;
|
||||
* ) SC="4.4BSD" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# NetBSD
|
||||
*:NetBSD:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
AP="${AT}"
|
||||
case "${AP}" in
|
||||
i[3-6]86 ) AP="iX86" ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'`
|
||||
ST="NetBSD ${r}"
|
||||
SP="${ST}"
|
||||
case "${r}" in
|
||||
0.* ) SC="4.3BSD" ;;
|
||||
* ) SC="4.4BSD" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# OpenBSD
|
||||
*:OpenBSD:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
AP="${AT}"
|
||||
case "${AP}" in
|
||||
i[3-6]86 ) AP="iX86" ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
r=`echo "${UNAME_RELEASE}" | sed -e 's/\([-_].*\)$/[\1]/'`
|
||||
ST="OpenBSD ${r}"
|
||||
SP="${ST}"
|
||||
SC="4.4BSD"
|
||||
;;
|
||||
|
||||
# GNU/Linux
|
||||
*:Linux:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
case "${AT}" in
|
||||
ia64 ) AT="IA64" ;;
|
||||
x86_64 ) AT='AMD64' ;;
|
||||
parisc ) AT="HPPA32" ;;
|
||||
parisc64 ) AT="HPPA64" ;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
case "${AP}" in
|
||||
i[3-6]86 ) AP='iX86' ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
v_kern=`echo "${UNAME_RELEASE}" |\
|
||||
sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
|
||||
v_libc=`(strings /lib/libc.so.* | grep '^GLIBC_' | sed -e 's/^GLIBC_//' |\
|
||||
env -i sort -n | sed -n -e '$p' | sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/') 2>/dev/null`
|
||||
ST="GNU/<Linux >${v_libc}/<${v_kern}>"
|
||||
if [ -f /etc/lsb-release ]; then
|
||||
eval `( . /etc/lsb-release
|
||||
echo "SC=\"LSB${LSB_VERSION}\""
|
||||
if [ ".${DISTRIB_ID}" != . -a ".${DISTRIB_RELEASE}" != . ]; then
|
||||
echo "SP=\"${DISTRIB_ID} ${DISTRIB_RELEASE}\""
|
||||
fi
|
||||
) 2>/dev/null`
|
||||
fi
|
||||
if [ ".$SP" = . ]; then
|
||||
for tagfile in x \
|
||||
`cd /etc && \
|
||||
/bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \
|
||||
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
|
||||
echo redhat-release lsb-release`
|
||||
do
|
||||
[ ".${tagfile}" = .x ] && continue
|
||||
[ ! -f "/etc/${tagfile}" ] && continue
|
||||
n=`echo ${tagfile} | sed -e 's/[_-]release$//' -e 's/[_-]version$//'`
|
||||
v=`(grep VERSION /etc/${tagfile}; cat /etc/${tagfile}) | grep '[0-9]' | sed -e 'q' |\
|
||||
sed -e 's/^/#/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#.*$//'`
|
||||
case "`util_lower ${n}`" in
|
||||
redhat )
|
||||
if [ ".`grep 'Red Hat Enterprise Linux' /etc/${tagfile}`" != . ]; then
|
||||
n="<R>ed <H>at <E>nterprise <L>inux"
|
||||
else
|
||||
n="<R>ed <H>at <L>inux"
|
||||
fi
|
||||
;;
|
||||
debian ) n="Debian[ GNU/Linux]" ;;
|
||||
ubuntu ) n="Ubuntu[ GNU/Linux]" ;;
|
||||
fedora ) n="<Fedora> Core[ GNU/Linux]" ;;
|
||||
suse ) n="SuSE[ Linux]" ;;
|
||||
mandrake*|mandriva ) n="Mandriva[ Linux]" ;;
|
||||
gentoo ) n="Gentoo[ GNU/Linux]" ;;
|
||||
slackware ) n="Slackware[ Linux]" ;;
|
||||
turbolinux ) n="TurboLinux" ;;
|
||||
unitedlinux ) n="UnitedLinux" ;;
|
||||
* ) n="${n}[ GNU/Linux]" ;;
|
||||
esac
|
||||
case "$n" in
|
||||
*"<"*">"* ) SP="$n <$v>" ;;
|
||||
* ) SP="$n $v" ;;
|
||||
esac
|
||||
break
|
||||
done
|
||||
fi
|
||||
[ ".$SP" = . ] && SP="${ST}"
|
||||
[ ".$SC" = . ] && SC="LSB"
|
||||
;;
|
||||
|
||||
# Sun Solaris
|
||||
*:SunOS:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
case "${AT}" in
|
||||
i86pc )
|
||||
AT="iX86"
|
||||
case "`(/bin/isainfo -k) 2>&1`" in
|
||||
amd64 ) AT="AMD64" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
case "${AP}" in
|
||||
sun4[cdm] ) AP="SPARC32" ;;
|
||||
sun4[uv] ) AP="SPARC64" ;;
|
||||
sun4* ) AP="SPARC" ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
case "${AC}" in
|
||||
SPARC* ) AC="SPARC" ;;
|
||||
esac
|
||||
# determine system
|
||||
ST="[Sun ]SunOS ${UNAME_RELEASE}"
|
||||
v=`echo "${UNAME_RELEASE}" |\
|
||||
sed -e 's;^4\.;1.;' \
|
||||
-e 's;^5\.\([0-6]\)[^0-9]*$;2.\1;' \
|
||||
-e 's;^5\.\([0-9][0-9]*\).*;\1;'`
|
||||
SP="[Sun ]Solaris $v"
|
||||
case "${UNAME_RELEASE}" in
|
||||
4.* ) SC="4.3BSD" ;;
|
||||
5.* ) SC="SVR4" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# SCO UnixWare
|
||||
*:UnixWare:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
case "${AT}" in
|
||||
i[3-6]86 | ix86at ) AT="iX86" ;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
# determine system
|
||||
v=`/sbin/uname -v`
|
||||
ST="[SCO ]UnixWare ${v}"
|
||||
SP="${ST}"
|
||||
SC="SVR${UNAME_RELEASE}"
|
||||
;;
|
||||
|
||||
# QNX
|
||||
*:QNX:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
case "${AT}" in
|
||||
x86pc ) AT="iX86" ;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
# determine system
|
||||
v="${UNAME_RELEASE}"
|
||||
ST="QNX[ Neutrino RTOS] ${v}"
|
||||
v=`echo "${v}" | sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;'`
|
||||
SP="QNX[ Neutrino RTOS] ${v}"
|
||||
SC="QNX"
|
||||
;;
|
||||
|
||||
# SGI IRIX
|
||||
*:IRIX*:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
AP="${AT}"
|
||||
case "${AP}:${UNAME_SYSTEM}" in
|
||||
IP*:IRIX64 ) AP="MIPS64" ;;
|
||||
IP*:* ) AP="MIPS" ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
v=`(/bin/uname -R || /bin/uname -r) 2>/dev/null | sed -e 's;[0-9.]* ;;'`
|
||||
ST="[SGI ]IRIX ${v}"
|
||||
v="${UNAME_RELEASE}"
|
||||
SP="[SGI ]IRIX ${v}"
|
||||
SC="4.2BSD/SVR3"
|
||||
;;
|
||||
|
||||
# HP HP-UX
|
||||
*:HP-UX:* )
|
||||
# determine architecture
|
||||
AT="${UNAME_MACHINE}"
|
||||
case "${AT}" in
|
||||
ia64 ) AT="IA64" ;;
|
||||
9000/[34]?? ) AT=M68K ;;
|
||||
9000/[678][0-9][0-9])
|
||||
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
case "${sc_cpu_version}" in
|
||||
523 ) AT="HPPA1.0" ;;
|
||||
528 ) AT="HPPA1.1" ;;
|
||||
532 ) AT="HPPA2.0"
|
||||
case "${sc_kernel_bits}" in
|
||||
32 ) AT="${AT}n" ;;
|
||||
64 ) AT="${AT}w" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
case "${AP}" in
|
||||
HPPA* ) AP="HPPA" ;;
|
||||
esac
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
v=`echo "${UNAME_RELEASE}" | sed -e 's;^[^0-9]*;;'`
|
||||
ST="[HP ]<HP>-<UX ${v}>"
|
||||
SP="${ST}"
|
||||
case "${v}" in
|
||||
10.* ) SC="SVR4.2" ;;
|
||||
[7-9]* ) SC="SVR4" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# HP Tru64 (OSF1)
|
||||
*:OSF1:* )
|
||||
# determine architecture
|
||||
AP="${UNAME_MACHINE}"
|
||||
case "${AP}" in
|
||||
alpha ) AP="Alpha" ;;
|
||||
esac
|
||||
alpha_type=`(/usr/sbin/psrinfo -v) 2>/dev/null |\
|
||||
sed -n -e 's/^.*The alpha \([^ ][^ ]*\).*processor.*$/\1/p' | sed -e 'q'`
|
||||
AT="${AP}${alpha_type}"
|
||||
AC="${AP}"
|
||||
# determine system
|
||||
v=`echo "${UNAME_RELEASE}" | sed -e 's;^[VTX];;'`
|
||||
ST="[HP ]Tru64 ${v}"
|
||||
SP="${ST}"
|
||||
SC="OSF1"
|
||||
;;
|
||||
|
||||
# IBM AIX
|
||||
*:AIX:* )
|
||||
cpu_arch=rs6000
|
||||
if [ -x /usr/sbin/lsdev -a -x /usr/sbin/lsattr ]; then
|
||||
cpu_id=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
if [ ".`/usr/sbin/lsattr -El ${cpu_id} | grep -i powerpc`" != . ]; then
|
||||
cpu_arch=powerpc
|
||||
fi
|
||||
elif [ -d /QOpenSys ]; then
|
||||
# IBM i5/OS (aka OS/400) with PASE (Portable Application Solutions Environment)
|
||||
cpu_arch=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ]; then
|
||||
os_level=`/usr/bin/oslevel`
|
||||
else
|
||||
os_level="`uname -v`.`uname -r`"
|
||||
fi
|
||||
os_level=`echo "${os_level}" |\
|
||||
sed -e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\)\(.*\)$;<\1>\2[\3];' \
|
||||
-e 's;^\([0-9][0-9]*\.[0-9][0-9]*\)\(.*\)$;<\1>\2;'`
|
||||
AT="${cpu_arch}"
|
||||
AP="${AT}"
|
||||
AC="${AP}"
|
||||
ST="[IBM ]<AIX >${os_level}"
|
||||
SP="${ST}"
|
||||
case "${os_level}" in
|
||||
[12]* ) SC="SVR2" ;;
|
||||
* ) SC="SVR4" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# Apple MacOS X Darwin
|
||||
*:Darwin:* )
|
||||
AT=`uname -p`
|
||||
case "${AT}" in
|
||||
powerpc ) AT="PPC" ;;
|
||||
esac
|
||||
AP="${AT}"
|
||||
AC="${AP}"
|
||||
case "${AC}" in
|
||||
i?86 ) AC="iX86" ;;
|
||||
esac
|
||||
ST="[Apple ]${UNAME_SYSTEM} ${UNAME_RELEASE}"
|
||||
SP="${ST}"
|
||||
SC="4.4BSD/Mach3"
|
||||
;;
|
||||
|
||||
# TODO ...ADD YOUR NEW PLATFORM CHECK HERE... TODO
|
||||
# *:XXX:* )
|
||||
# ...
|
||||
# ;;
|
||||
|
||||
# ...A STILL UNKNOWN PLATFORM...
|
||||
* )
|
||||
AT=`echo "${UNAME_MACHINE}" | sed -e "s; ;${opt_C};g"`
|
||||
AP="${AT}"
|
||||
AC="${AP}"
|
||||
v=`echo "${UNAME_RELEASE}" |\
|
||||
sed -e 's/^/#/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
|
||||
-e 's/^#.*$/?/'`
|
||||
ST="${UNAME_SYSTEM} ${v}"
|
||||
SP="${ST}"
|
||||
SC="${SP}"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# provide fallback values
|
||||
[ ".$AT" = . ] && AT="${AP:-${AC}}"
|
||||
[ ".$AP" = . ] && AP="${AT:-${AC}}"
|
||||
[ ".$AC" = . ] && AC="${AP:-${AT}}"
|
||||
[ ".$ST" = . ] && ST="${SP:-${SC}}"
|
||||
[ ".$SP" = . ] && SP="${ST:-${SC}}"
|
||||
[ ".$SC" = . ] && SC="${SP:-${ST}}"
|
||||
|
||||
# support explicit enforced verbose/concise output
|
||||
if [ ".$opt_v" = .yes ]; then
|
||||
opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%[\1]/g'`
|
||||
elif [ ".$opt_c" = .yes ]; then
|
||||
opt_F=`echo ":$opt_F" | sed -e 's/^://' -e 's/%\([as][cpt]\)/%<\1>/g'`
|
||||
fi
|
||||
|
||||
# provide verbose and concise variants
|
||||
AC_V=""; AC_N=""; AC_C=""
|
||||
AP_V=""; AP_N=""; AP_C=""
|
||||
AT_V=""; AT_N=""; AT_C=""
|
||||
SC_V=""; SC_N=""; SC_C=""
|
||||
SP_V=""; SP_N=""; SP_C=""
|
||||
ST_V=""; ST_N=""; ST_C=""
|
||||
for var_lc in at ap ac st sp sc; do
|
||||
case "$opt_F" in
|
||||
*"%[${val_lc}]"* | *"%{${val_lc}}"* | *"%${val_lc}"* | *"%<${val_lc}>"* )
|
||||
var_uc=`util_upper "$var_lc"`
|
||||
eval "val=\"\$${var_uc}\""
|
||||
val_V=""; val_N=""; val_C=""
|
||||
case "$opt_F" in
|
||||
*"%[${var_lc}]"* )
|
||||
val_V=`echo ":$val" | \
|
||||
sed -e 's/^://' \
|
||||
-e 's;\[\([^]]*\)\];\1;g' \
|
||||
-e 's;<\([^>]*\)>;\1;g' \
|
||||
-e "s; ;§§;g" \
|
||||
-e "s;/;%%;g" \
|
||||
-e "s;§§;${opt_S};g" \
|
||||
-e "s;%%;${opt_C};g"`
|
||||
eval "${var_uc}_V=\"\${val_V}\""
|
||||
;;
|
||||
esac
|
||||
case "$opt_F" in
|
||||
*"%{${var_lc}}"* | *"%${var_lc}"* )
|
||||
val_N=`echo ":$val" | \
|
||||
sed -e 's/^://' \
|
||||
-e 's;\[\([^]]*\)\];;g' \
|
||||
-e 's;<\([^>]*\)>;\1;g' \
|
||||
-e "s; ;§§;g" \
|
||||
-e "s;/;%%;g" \
|
||||
-e "s;§§;${opt_S};g" \
|
||||
-e "s;%%;${opt_C};g"`
|
||||
eval "${var_uc}_N=\"\${val_N}\""
|
||||
;;
|
||||
esac
|
||||
case "$opt_F" in
|
||||
*"%<${var_lc}>"* )
|
||||
val_C=`echo ":$val" | \
|
||||
sed -e 's/^://' \
|
||||
-e 's;\[\([^]]*\)\];;g' \
|
||||
-e 's;[^<]*<\([^>]*\)>[^<]*;\1;g' \
|
||||
-e "s; ;§§;g" \
|
||||
-e "s;/;%%;g" \
|
||||
-e "s;§§;${opt_S};g" \
|
||||
-e "s;%%;${opt_C};g"`
|
||||
eval "${var_uc}_C=\"\${val_C}\""
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# create output string
|
||||
output=`echo ":$opt_F" |\
|
||||
sed -e "s/^://" \
|
||||
-e "s;%\\[ac\\];${AC_V};g" \
|
||||
-e "s;%{ac};${AC_N};g" \
|
||||
-e "s;%ac;${AC_N};g" \
|
||||
-e "s;%<ac>;${AC_C};g" \
|
||||
-e "s;%\\[ap\\];${AP_V};g" \
|
||||
-e "s;%{ap};${AP_N};g" \
|
||||
-e "s;%ap;${AP_N};g" \
|
||||
-e "s;%<ap>;${AP_C};g" \
|
||||
-e "s;%\\[at\\];${AT_V};g" \
|
||||
-e "s;%{at};${AT_N};g" \
|
||||
-e "s;%at;${AT_N};g" \
|
||||
-e "s;%<at>;${AT_C};g" \
|
||||
-e "s;%\\[sc\\];${SC_V};g" \
|
||||
-e "s;%{sc};${SC_N};g" \
|
||||
-e "s;%sc;${SC_N};g" \
|
||||
-e "s;%<sc>;${SC_C};g" \
|
||||
-e "s;%\\[sp\\];${SP_V};g" \
|
||||
-e "s;%{sp};${SP_N};g" \
|
||||
-e "s;%sp;${SP_N};g" \
|
||||
-e "s;%<sp>;${SP_C};g" \
|
||||
-e "s;%\\[st\\];${ST_V};g" \
|
||||
-e "s;%{st};${ST_N};g" \
|
||||
-e "s;%st;${ST_N};g" \
|
||||
-e "s;%<st>;${ST_C};g" \
|
||||
-e 's/\\\\n/^/g' |\
|
||||
tr '^' '\012'`
|
||||
|
||||
# support lower/upper-case mapping
|
||||
if [ ".$opt_L" = .yes ]; then
|
||||
output=`util_lower "$output"`
|
||||
elif [ ".$opt_U" = .yes ]; then
|
||||
output=`util_upper "$output"`
|
||||
fi
|
||||
|
||||
# display output string
|
||||
if [ ".$opt_n" = .yes ]; then
|
||||
echo . | awk '{ printf("%s", output); }' output="$output"
|
||||
else
|
||||
echo "$output"
|
||||
fi
|
||||
|
||||
shtool_exit 0
|
||||
;;
|
||||
|
||||
path )
|
||||
##
|
||||
## path -- Deal with program paths
|
||||
## Copyright (c) 1998-2006 Ralf S. Engelschall <rse@engelschall.com>
|
||||
## Copyright (c) 1998-2005 Ralf S. Engelschall <rse@engelschall.com>
|
||||
##
|
||||
|
||||
namelist="$*"
|
||||
|
||||
+2
-2
@@ -37,8 +37,8 @@ AC_CONFIG_HEADER(main/php_config.h)
|
||||
|
||||
MAJOR_VERSION=4
|
||||
MINOR_VERSION=4
|
||||
RELEASE_VERSION=8
|
||||
EXTRA_VERSION="RC1"
|
||||
RELEASE_VERSION=5
|
||||
EXTRA_VERSION="RC2"
|
||||
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
|
||||
|
||||
dnl Define where extension directories are located in the configure context
|
||||
|
||||
+1
-5
@@ -171,10 +171,6 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
#else
|
||||
path_copy = path;
|
||||
#endif
|
||||
|
||||
if ((PG(safe_mode) && (!php_checkuid(path_copy, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(path_copy TSRMLS_CC)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* try and open it directly first */
|
||||
bz_file = BZ2_bzopen(path_copy, mode);
|
||||
@@ -186,7 +182,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
|
||||
|
||||
if (bz_file == NULL) {
|
||||
/* that didn't work, so try and get something from the network/wrapper */
|
||||
stream = php_stream_open_wrapper(path, mode, options | STREAM_WILL_CAST | ENFORCE_SAFE_MODE, opened_path);
|
||||
stream = php_stream_open_wrapper(path, mode, options | STREAM_WILL_CAST, opened_path);
|
||||
|
||||
if (stream) {
|
||||
int fd;
|
||||
|
||||
+12
-18
@@ -559,9 +559,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
|
||||
case PHP_CURL_FILE:
|
||||
return fwrite(data, size, nmemb, t->fp);
|
||||
case PHP_CURL_RETURN:
|
||||
if (length > 0) {
|
||||
smart_str_appendl(&t->buf, data, (int) length);
|
||||
}
|
||||
smart_str_appendl(&t->buf, data, (int) length);
|
||||
break;
|
||||
case PHP_CURL_USER: {
|
||||
zval *argv[2];
|
||||
@@ -676,11 +674,10 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
|
||||
case PHP_CURL_STDOUT:
|
||||
/* Handle special case write when we're returning the entire transfer
|
||||
*/
|
||||
if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) {
|
||||
if (ch->handlers->write->method == PHP_CURL_RETURN)
|
||||
smart_str_appendl(&ch->handlers->write->buf, data, (int) length);
|
||||
} else {
|
||||
else
|
||||
PHPWRITE(data, length);
|
||||
}
|
||||
break;
|
||||
case PHP_CURL_FILE:
|
||||
return fwrite(data, size, nmemb, t->fp);
|
||||
@@ -1262,9 +1259,12 @@ PHP_FUNCTION(curl_setopt)
|
||||
static void
|
||||
cleanup_handle(php_curl *ch)
|
||||
{
|
||||
if (ch->handlers->write->buf.len > 0) {
|
||||
smart_str_free(&ch->handlers->write->buf);
|
||||
ch->handlers->write->buf.len = 0;
|
||||
if (ch->uses < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch->handlers->write->buf.len) {
|
||||
memset(&ch->handlers->write->buf, 0, sizeof(smart_str));
|
||||
}
|
||||
|
||||
memset(ch->err.str, 0, CURL_ERROR_SIZE + 1);
|
||||
@@ -1294,7 +1294,6 @@ PHP_FUNCTION(curl_exec)
|
||||
if (error != CURLE_OK && error != CURLE_PARTIAL_FILE) {
|
||||
if (ch->handlers->write->buf.len > 0) {
|
||||
smart_str_free(&ch->handlers->write->buf);
|
||||
ch->handlers->write->buf.len = 0;
|
||||
}
|
||||
|
||||
RETURN_FALSE;
|
||||
@@ -1304,14 +1303,13 @@ PHP_FUNCTION(curl_exec)
|
||||
|
||||
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) {
|
||||
--ch->uses;
|
||||
if (ch->handlers->write->type != PHP_CURL_BINARY) {
|
||||
if (ch->handlers->write->type != PHP_CURL_BINARY)
|
||||
smart_str_0(&ch->handlers->write->buf);
|
||||
}
|
||||
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1);
|
||||
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 0);
|
||||
}
|
||||
--ch->uses;
|
||||
if (ch->handlers->write->method == PHP_CURL_RETURN) {
|
||||
RETURN_EMPTY_STRING();
|
||||
RETURN_STRINGL("", sizeof("") - 1, 0);
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
@@ -1532,10 +1530,6 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
zend_llist_clean(&ch->to_free.slist);
|
||||
zend_llist_clean(&ch->to_free.post);
|
||||
|
||||
if (ch->handlers->write->buf.len > 0) {
|
||||
smart_str_free(&ch->handlers->write->buf);
|
||||
ch->handlers->write->buf.len = 0;
|
||||
}
|
||||
if (ch->handlers->write->func) {
|
||||
FREE_ZVAL(ch->handlers->write->func);
|
||||
ch->handlers->read->func = NULL;
|
||||
|
||||
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOMXML" /D ZTS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_STATIC=1 /D LIBXSLT_STATIC=1 /D "LIBXML_THREAD_ENABLED" /D HAVE_DOMEXSLT=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_STATIC=1 /D LIBXSLT_STATIC=1 /D "LIBXML_THREAD_ENABLED" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x406 /d "NDEBUG"
|
||||
@@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 wsock32.lib php4ts.lib libxml2_a.lib libxslt_a.lib libexslt_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_domxml.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
# ADD LINK32 wsock32.lib php4ts.lib libxml2_a.lib libxslt_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_domxml.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "domxml - Win32 Debug_TS"
|
||||
@@ -72,7 +72,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "mssql-70" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOMXML" /D ZTS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_STATIC=1 /D LIBXSLT_STATIC=1 /D "LIBXML_THREAD_ENABLED" /D HAVE_DOMEXSLT=1 /FR /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_STATIC=1 /D LIBXSLT_STATIC=1 /D "LIBXML_THREAD_ENABLED" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x406 /d "NDEBUG"
|
||||
@@ -82,7 +82,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts_debug.lib libxml2_a.lib libxslt_a.lib libexslt_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS/php_domxml.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
# ADD LINK32 php4ts_debug.lib libxml2_a.lib libxslt_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS/php_domxml.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
+668
@@ -0,0 +1,668 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2007 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Rasmus Lerdorf <rasmus@php.net> |
|
||||
| Jim Winstead <jimw@php.net> |
|
||||
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "php.h"
|
||||
#include "php_string.h"
|
||||
#include "reg.h"
|
||||
#include "ext/standard/info.h"
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(reg)
|
||||
|
||||
typedef struct {
|
||||
regex_t preg;
|
||||
int cflags;
|
||||
} reg_cache;
|
||||
|
||||
static int reg_magic = 0;
|
||||
|
||||
/* {{{ _php_regcomp
|
||||
*/
|
||||
static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
|
||||
{
|
||||
int r = 0;
|
||||
int patlen = strlen(pattern);
|
||||
reg_cache *rc = NULL;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if(zend_hash_find(®(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
|
||||
&& rc->cflags == cflags) {
|
||||
#ifdef HAVE_REGEX_T_RE_MAGIC
|
||||
/*
|
||||
* We use a saved magic number to see whether cache is corrupted, and if it
|
||||
* is, we flush it and compile the pattern from scratch.
|
||||
*/
|
||||
if (rc->preg.re_magic != reg_magic) {
|
||||
zend_hash_clean(®(ht_rc));
|
||||
} else {
|
||||
memcpy(preg, &rc->preg, sizeof(*preg));
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
r = regcomp(preg, pattern, cflags);
|
||||
if(!r) {
|
||||
reg_cache rcp;
|
||||
|
||||
rcp.cflags = cflags;
|
||||
memcpy(&rcp.preg, preg, sizeof(*preg));
|
||||
/*
|
||||
* Since we don't have access to the actual MAGIC1 definition in the private
|
||||
* header file, we save the magic value immediately after compilation. Hopefully,
|
||||
* it's good.
|
||||
*/
|
||||
if (!reg_magic) reg_magic = preg->re_magic;
|
||||
zend_hash_update(®(ht_rc), (char *) pattern, patlen+1,
|
||||
(void *) &rcp, sizeof(rcp), NULL);
|
||||
}
|
||||
#else
|
||||
memcpy(preg, &rc->preg, sizeof(*preg));
|
||||
} else {
|
||||
r = regcomp(preg, pattern, cflags);
|
||||
if(!r) {
|
||||
reg_cache rcp;
|
||||
|
||||
rcp.cflags = cflags;
|
||||
memcpy(&rcp.preg, preg, sizeof(*preg));
|
||||
zend_hash_update(®(ht_rc), (char *) pattern, patlen+1,
|
||||
(void *) &rcp, sizeof(rcp), NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void _free_reg_cache(reg_cache *rc)
|
||||
{
|
||||
regfree(&rc->preg);
|
||||
}
|
||||
|
||||
#undef regfree
|
||||
#define regfree(a);
|
||||
#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)
|
||||
{
|
||||
zend_hash_init(®_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
|
||||
}
|
||||
|
||||
static void php_reg_destroy_globals(zend_reg_globals *reg_globals TSRMLS_DC)
|
||||
{
|
||||
zend_hash_destroy(®_globals->ht_rc);
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(regex)
|
||||
{
|
||||
ZEND_INIT_MODULE_GLOBALS(reg, php_reg_init_globals, php_reg_destroy_globals);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(regex)
|
||||
{
|
||||
#ifndef ZTS
|
||||
php_reg_destroy_globals(®_globals TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(regex)
|
||||
{
|
||||
#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_reg_eprint
|
||||
* php_reg_eprint - convert error number to name
|
||||
*/
|
||||
static void php_reg_eprint(int err, regex_t *re) {
|
||||
char *buf = NULL, *message = NULL;
|
||||
size_t len;
|
||||
size_t buf_len;
|
||||
|
||||
#ifdef REG_ITOA
|
||||
/* get the length of the message */
|
||||
buf_len = regerror(REG_ITOA | err, re, NULL, 0);
|
||||
if (buf_len) {
|
||||
buf = (char *)safe_emalloc(buf_len, sizeof(char), 0);
|
||||
if (!buf) return; /* fail silently */
|
||||
/* finally, get the error message */
|
||||
regerror(REG_ITOA | err, re, buf, buf_len);
|
||||
}
|
||||
#else
|
||||
buf_len = 0;
|
||||
#endif
|
||||
len = regerror(err, re, NULL, 0);
|
||||
if (len) {
|
||||
TSRMLS_FETCH();
|
||||
|
||||
message = (char *)safe_emalloc((buf_len + len + 2), sizeof(char), 0);
|
||||
if (!message) {
|
||||
return; /* fail silently */
|
||||
}
|
||||
if (buf_len) {
|
||||
snprintf(message, buf_len, "%s: ", buf);
|
||||
buf_len += 1; /* so pointer math below works */
|
||||
}
|
||||
/* drop the message into place */
|
||||
regerror(err, re, message + buf_len, len);
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", message);
|
||||
}
|
||||
|
||||
STR_FREE(buf);
|
||||
STR_FREE(message);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_ereg
|
||||
*/
|
||||
static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
{
|
||||
pval **regex, /* Regular expression */
|
||||
**findin, /* String to apply expression to */
|
||||
**array = NULL; /* Optional register array */
|
||||
regex_t re;
|
||||
regmatch_t *subs;
|
||||
int err, match_len, string_len;
|
||||
uint i;
|
||||
int copts = 0;
|
||||
off_t start, end;
|
||||
char *buf = NULL;
|
||||
char *string = NULL;
|
||||
int argc = ZEND_NUM_ARGS();
|
||||
|
||||
if (argc < 2 || argc > 3 ||
|
||||
zend_get_parameters_ex(argc, ®ex, &findin, &array) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
if (icase)
|
||||
copts |= REG_ICASE;
|
||||
|
||||
if (argc == 2)
|
||||
copts |= REG_NOSUB;
|
||||
|
||||
/* compile the regular expression from the supplied regex */
|
||||
if (Z_TYPE_PP(regex) == IS_STRING) {
|
||||
err = regcomp(&re, Z_STRVAL_PP(regex), REG_EXTENDED | copts);
|
||||
} else {
|
||||
/* we convert numbers to integers and treat them as a string */
|
||||
if (Z_TYPE_PP(regex) == IS_DOUBLE)
|
||||
convert_to_long_ex(regex); /* get rid of decimal places */
|
||||
convert_to_string_ex(regex);
|
||||
/* don't bother doing an extended regex with just a number */
|
||||
err = regcomp(&re, Z_STRVAL_PP(regex), copts);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* make a copy of the string we're looking in */
|
||||
convert_to_string_ex(findin);
|
||||
string = estrndup(Z_STRVAL_PP(findin), Z_STRLEN_PP(findin));
|
||||
|
||||
/* allocate storage for (sub-)expression-matches */
|
||||
subs = (regmatch_t *)ecalloc(sizeof(regmatch_t),re.re_nsub+1);
|
||||
|
||||
/* 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);
|
||||
regfree(&re);
|
||||
efree(subs);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
match_len = 1;
|
||||
|
||||
if (array && err != REG_NOMATCH) {
|
||||
match_len = (int) (subs[0].rm_eo - subs[0].rm_so);
|
||||
string_len = Z_STRLEN_PP(findin) + 1;
|
||||
|
||||
buf = emalloc(string_len);
|
||||
|
||||
zval_dtor(*array); /* start with clean array */
|
||||
array_init(*array);
|
||||
|
||||
for (i = 0; i <= re.re_nsub; i++) {
|
||||
start = subs[i].rm_so;
|
||||
end = subs[i].rm_eo;
|
||||
if (start != -1 && end > 0 && start < string_len && end < string_len && start < end) {
|
||||
add_index_stringl(*array, i, string+start, end-start, 1);
|
||||
} else {
|
||||
add_index_bool(*array, i, 0);
|
||||
}
|
||||
}
|
||||
efree(buf);
|
||||
}
|
||||
|
||||
efree(subs);
|
||||
efree(string);
|
||||
if (err == REG_NOMATCH) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
if (match_len == 0)
|
||||
match_len = 1;
|
||||
RETVAL_LONG(match_len);
|
||||
}
|
||||
regfree(&re);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int ereg(string pattern, string string [, array registers])
|
||||
Regular expression match */
|
||||
PHP_FUNCTION(ereg)
|
||||
{
|
||||
php_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int eregi(string pattern, string string [, array registers])
|
||||
Case-insensitive regular expression match */
|
||||
PHP_FUNCTION(eregi)
|
||||
{
|
||||
php_ereg(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_reg_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)
|
||||
{
|
||||
regex_t re;
|
||||
regmatch_t *subs;
|
||||
|
||||
char *buf, /* buf is where we build the replaced string */
|
||||
*nbuf, /* nbuf is used when we grow the buffer */
|
||||
*walkbuf; /* used to walk buf when replacing backrefs */
|
||||
const char *walk; /* used to walk replacement string for backrefs */
|
||||
int buf_len;
|
||||
int pos, tmp, string_len, new_l;
|
||||
int err, copts = 0;
|
||||
|
||||
string_len = strlen(string);
|
||||
|
||||
if (icase) {
|
||||
copts = REG_ICASE;
|
||||
}
|
||||
if (extended) {
|
||||
copts |= REG_EXTENDED;
|
||||
}
|
||||
|
||||
err = regcomp(&re, pattern, copts);
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
return ((char *) -1);
|
||||
}
|
||||
|
||||
|
||||
/* allocate storage for (sub-)expression-matches */
|
||||
subs = (regmatch_t *)ecalloc(sizeof(regmatch_t),re.re_nsub+1);
|
||||
|
||||
/* start with a buffer that is twice the size of the stringo
|
||||
we're doing replacements in */
|
||||
buf_len = 2 * string_len + 1;
|
||||
buf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
|
||||
err = pos = 0;
|
||||
buf[0] = '\0';
|
||||
while (!err) {
|
||||
err = regexec(&re, &string[pos], re.re_nsub+1, subs, (pos ? REG_NOTBOL : 0));
|
||||
|
||||
if (err && err != REG_NOMATCH) {
|
||||
php_reg_eprint(err, &re);
|
||||
efree(subs);
|
||||
efree(buf);
|
||||
regfree(&re);
|
||||
return ((char *) -1);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
/* backref replacement is done in two passes:
|
||||
1) find out how long the string will be, and allocate buf
|
||||
2) copy the part before match, replacement and backrefs to buf
|
||||
|
||||
Jaakko Hyvätti <Jaakko.Hyvatti@iki.fi>
|
||||
*/
|
||||
|
||||
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
|
||||
walk = replace;
|
||||
while (*walk) {
|
||||
if ('\\' == *walk && isdigit((unsigned char)walk[1]) && ((unsigned char)walk[1]) - '0' <= re.re_nsub) {
|
||||
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
|
||||
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
|
||||
}
|
||||
walk += 2;
|
||||
} else {
|
||||
new_l++;
|
||||
walk++;
|
||||
}
|
||||
}
|
||||
if (new_l + 1 > buf_len) {
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = emalloc(buf_len);
|
||||
strcpy(nbuf, buf);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
}
|
||||
tmp = strlen(buf);
|
||||
/* copy the part of the string before the match */
|
||||
strncat(buf, &string[pos], subs[0].rm_so);
|
||||
|
||||
/* copy replacement and backrefs */
|
||||
walkbuf = &buf[tmp + subs[0].rm_so];
|
||||
walk = replace;
|
||||
while (*walk) {
|
||||
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= re.re_nsub) {
|
||||
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1
|
||||
/* this next case shouldn't happen. it does. */
|
||||
&& subs[walk[1] - '0'].rm_so <= subs[walk[1] - '0'].rm_eo) {
|
||||
|
||||
tmp = subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
|
||||
memcpy (walkbuf, &string[pos + subs[walk[1] - '0'].rm_so], tmp);
|
||||
walkbuf += tmp;
|
||||
}
|
||||
walk += 2;
|
||||
} else {
|
||||
*walkbuf++ = *walk++;
|
||||
}
|
||||
}
|
||||
*walkbuf = '\0';
|
||||
|
||||
/* and get ready to keep looking for replacements */
|
||||
if (subs[0].rm_so == subs[0].rm_eo) {
|
||||
if (subs[0].rm_so + pos >= string_len) {
|
||||
break;
|
||||
}
|
||||
new_l = strlen (buf) + 1;
|
||||
if (new_l + 1 > buf_len) {
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
strcpy(nbuf, buf);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
}
|
||||
pos += subs[0].rm_eo + 1;
|
||||
buf [new_l-1] = string [pos-1];
|
||||
buf [new_l] = '\0';
|
||||
} else {
|
||||
pos += subs[0].rm_eo;
|
||||
}
|
||||
} else { /* REG_NOMATCH */
|
||||
new_l = strlen(buf) + strlen(&string[pos]);
|
||||
if (new_l + 1 > buf_len) {
|
||||
buf_len = new_l + 1; /* now we know exactly how long it is */
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
strcpy(nbuf, buf);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
}
|
||||
/* stick that last bit of string on our output */
|
||||
strcat(buf, &string[pos]);
|
||||
}
|
||||
}
|
||||
|
||||
/* don't want to leak memory .. */
|
||||
efree(subs);
|
||||
regfree(&re);
|
||||
|
||||
/* whew. */
|
||||
return (buf);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_ereg_replace
|
||||
*/
|
||||
static void php_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
{
|
||||
pval **arg_pattern,
|
||||
**arg_replace,
|
||||
**arg_string;
|
||||
char *pattern;
|
||||
char *string;
|
||||
char *replace;
|
||||
char *ret;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 3 ||
|
||||
zend_get_parameters_ex(3, &arg_pattern, &arg_replace, &arg_string) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
if (Z_TYPE_PP(arg_pattern) == IS_STRING) {
|
||||
if (Z_STRVAL_PP(arg_pattern) && Z_STRLEN_PP(arg_pattern))
|
||||
pattern = estrndup(Z_STRVAL_PP(arg_pattern), Z_STRLEN_PP(arg_pattern));
|
||||
else
|
||||
pattern = empty_string;
|
||||
} else {
|
||||
convert_to_long_ex(arg_pattern);
|
||||
pattern = emalloc(2);
|
||||
pattern[0] = (char) Z_LVAL_PP(arg_pattern);
|
||||
pattern[1] = '\0';
|
||||
}
|
||||
|
||||
if (Z_TYPE_PP(arg_replace) == IS_STRING) {
|
||||
if (Z_STRVAL_PP(arg_replace) && Z_STRLEN_PP(arg_replace))
|
||||
replace = estrndup(Z_STRVAL_PP(arg_replace), Z_STRLEN_PP(arg_replace));
|
||||
else
|
||||
replace = empty_string;
|
||||
} else {
|
||||
convert_to_long_ex(arg_replace);
|
||||
replace = emalloc(2);
|
||||
replace[0] = (char) Z_LVAL_PP(arg_replace);
|
||||
replace[1] = '\0';
|
||||
}
|
||||
|
||||
convert_to_string_ex(arg_string);
|
||||
if (Z_STRVAL_PP(arg_string) && Z_STRLEN_PP(arg_string))
|
||||
string = estrndup(Z_STRVAL_PP(arg_string), Z_STRLEN_PP(arg_string));
|
||||
else
|
||||
string = empty_string;
|
||||
|
||||
/* do the actual work */
|
||||
ret = php_reg_replace(pattern, replace, string, icase, 1);
|
||||
if (ret == (char *) -1) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_STRING(ret, 1);
|
||||
STR_FREE(ret);
|
||||
}
|
||||
|
||||
STR_FREE(string);
|
||||
STR_FREE(replace);
|
||||
STR_FREE(pattern);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ereg_replace(string pattern, string replacement, string string)
|
||||
Replace regular expression */
|
||||
PHP_FUNCTION(ereg_replace)
|
||||
{
|
||||
php_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string eregi_replace(string pattern, string replacement, string string)
|
||||
Case insensitive replace regular expression */
|
||||
PHP_FUNCTION(eregi_replace)
|
||||
{
|
||||
php_ereg_replace(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_split
|
||||
*/
|
||||
static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
{
|
||||
zval **spliton, **str, **arg_count = NULL;
|
||||
regex_t re;
|
||||
regmatch_t subs[1];
|
||||
char *strp, *endp;
|
||||
int err, size, count = -1, copts = 0;
|
||||
int argc = ZEND_NUM_ARGS();
|
||||
|
||||
if (argc < 2 || argc > 3 ||
|
||||
zend_get_parameters_ex(argc, &spliton, &str, &arg_count) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
convert_to_long_ex(arg_count);
|
||||
count = Z_LVAL_PP(arg_count);
|
||||
}
|
||||
|
||||
if (icase)
|
||||
copts = REG_ICASE;
|
||||
|
||||
convert_to_string_ex(spliton);
|
||||
convert_to_string_ex(str);
|
||||
|
||||
strp = Z_STRVAL_PP(str);
|
||||
endp = strp + Z_STRLEN_PP(str);
|
||||
|
||||
err = regcomp(&re, Z_STRVAL_PP(spliton), REG_EXTENDED | copts);
|
||||
if (err) {
|
||||
php_reg_eprint(err, &re);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
/* churn through str, generating array entries as we go */
|
||||
while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0))) {
|
||||
if (subs[0].rm_so == 0 && subs[0].rm_eo) {
|
||||
/* match is at start of string, return empty string */
|
||||
add_next_index_stringl(return_value, empty_string, 0, 1);
|
||||
/* skip ahead the length of the regex match */
|
||||
strp += subs[0].rm_eo;
|
||||
} else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
|
||||
/* No more matches */
|
||||
regfree(&re);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Regular Expression to split()");
|
||||
zend_hash_destroy(Z_ARRVAL_P(return_value));
|
||||
efree(Z_ARRVAL_P(return_value));
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
/* On a real match */
|
||||
|
||||
/* make a copy of the substring */
|
||||
size = subs[0].rm_so;
|
||||
|
||||
/* add it to the array */
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
/* point at our new starting point */
|
||||
strp = strp + subs[0].rm_eo;
|
||||
}
|
||||
|
||||
/* if we're only looking for a certain number of points,
|
||||
stop looking once we hit it */
|
||||
if (count != -1) {
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
/* see if we encountered an error */
|
||||
if (err && err != REG_NOMATCH) {
|
||||
php_reg_eprint(err, &re);
|
||||
regfree(&re);
|
||||
zend_hash_destroy(Z_ARRVAL_P(return_value));
|
||||
efree(Z_ARRVAL_P(return_value));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* otherwise we just have one last element to add to the array */
|
||||
size = endp - strp;
|
||||
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
regfree(&re);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array split(string pattern, string string [, int limit])
|
||||
Split string into array by regular expression */
|
||||
PHP_FUNCTION(split)
|
||||
{
|
||||
php_split(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array spliti(string pattern, string string [, int limit])
|
||||
Split string into array by regular expression case-insensitive */
|
||||
|
||||
PHP_FUNCTION(spliti)
|
||||
{
|
||||
php_split(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string sql_regcase(string string)
|
||||
Make regular expression for case insensitive match */
|
||||
PHPAPI PHP_FUNCTION(sql_regcase)
|
||||
{
|
||||
zval **string;
|
||||
char *tmp;
|
||||
unsigned char c;
|
||||
register int i, j;
|
||||
|
||||
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &string)==FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(string);
|
||||
|
||||
tmp = safe_emalloc(Z_STRLEN_PP(string), 4, 1);
|
||||
|
||||
for (i = j = 0; i < Z_STRLEN_PP(string); i++) {
|
||||
c = (unsigned char) Z_STRVAL_PP(string)[i];
|
||||
if(isalpha(c)) {
|
||||
tmp[j++] = '[';
|
||||
tmp[j++] = toupper(c);
|
||||
tmp[j++] = tolower(c);
|
||||
tmp[j++] = ']';
|
||||
} else {
|
||||
tmp[j++] = c;
|
||||
}
|
||||
}
|
||||
tmp[j] = 0;
|
||||
|
||||
RETVAL_STRINGL(tmp, j, 1);
|
||||
efree(tmp);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2007 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef REG_H
|
||||
#define REG_H
|
||||
|
||||
PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended);
|
||||
|
||||
PHP_FUNCTION(ereg);
|
||||
PHP_FUNCTION(eregi);
|
||||
PHP_FUNCTION(eregi_replace);
|
||||
PHP_FUNCTION(ereg_replace);
|
||||
PHP_FUNCTION(split);
|
||||
PHP_FUNCTION(spliti);
|
||||
PHPAPI PHP_FUNCTION(sql_regcase);
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(reg)
|
||||
HashTable ht_rc;
|
||||
ZEND_END_MODULE_GLOBALS(reg)
|
||||
|
||||
PHP_MINIT_FUNCTION(regex);
|
||||
PHP_MSHUTDOWN_FUNCTION(regex);
|
||||
PHP_MINFO_FUNCTION(regex);
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
#define REG(v) TSRMG(reg_globals_id, zend_reg_globals *, v)
|
||||
#else
|
||||
#define REG(v) (reg_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* REG_H */
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef PHP_REGEX_H
|
||||
#define PHP_REGEX_H
|
||||
|
||||
/*
|
||||
* REGEX means:
|
||||
* 0.. system regex
|
||||
* 1.. bundled regex
|
||||
*/
|
||||
|
||||
#if REGEX
|
||||
/* get aliases */
|
||||
#include "regex/regex_extra.h"
|
||||
#include "regex/regex.h"
|
||||
|
||||
/* get rid of aliases */
|
||||
#define PHP_NO_ALIASES
|
||||
#include "regex/regex_extra.h"
|
||||
#undef PHP_NO_ALIASES
|
||||
|
||||
#undef _PCREPOSIX_H
|
||||
#define _PCREPOSIX_H 1
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */
|
||||
#endif
|
||||
#ifndef _REGEX_H_
|
||||
#define _REGEX_H_ 1
|
||||
#endif
|
||||
#ifndef _RX_H
|
||||
#define _RX_H 1 /* Try defining these for Linux to */
|
||||
#endif
|
||||
#ifndef __REGEXP_LIBRARY_H__
|
||||
#define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */
|
||||
#endif
|
||||
#ifndef _H_REGEX
|
||||
#define _H_REGEX 1 /* This one is for AIX */
|
||||
#endif
|
||||
#elif REGEX == 0
|
||||
#include <regex.h>
|
||||
#ifndef _REGEX_H_
|
||||
#define _REGEX_H_ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* PHP_REGEX_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
|
||||
This software is not subject to any license of the American Telephone
|
||||
and Telegraph Company or of the Regents of the University of California.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose on
|
||||
any computer system, and to alter it and redistribute it, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The author is not responsible for the consequences of use of this
|
||||
software, no matter how awful, even if they arise from flaws in it.
|
||||
|
||||
2. The origin of this software must not be misrepresented, either by
|
||||
explicit claim or by omission. Since few users ever read sources,
|
||||
credits must appear in the documentation.
|
||||
|
||||
3. Altered versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software. Since few users
|
||||
ever read sources, credits must appear in the documentation.
|
||||
|
||||
4. This notice may not be removed or altered.
|
||||
@@ -0,0 +1,32 @@
|
||||
alpha3.4 release.
|
||||
Thu Mar 17 23:17:18 EST 1994
|
||||
henry@zoo.toronto.edu
|
||||
|
||||
See WHATSNEW for change listing.
|
||||
|
||||
installation notes:
|
||||
--------
|
||||
Read the comments at the beginning of Makefile before running.
|
||||
|
||||
Utils.h contains some things that just might have to be modified on
|
||||
some systems, as well as a nested include (ugh) of <assert.h>.
|
||||
|
||||
The "fake" directory contains quick-and-dirty fakes for some header
|
||||
files and routines that old systems may not have. Note also that
|
||||
-DUSEBCOPY will make utils.h substitute bcopy() for memmove().
|
||||
|
||||
After that, "make r" will build regcomp.o, regexec.o, regfree.o,
|
||||
and regerror.o (the actual routines), bundle them together into a test
|
||||
program, and run regression tests on them. No output is good output.
|
||||
|
||||
"make lib" builds just the .o files for the actual routines (when
|
||||
you're happy with testing and have adjusted CFLAGS for production),
|
||||
and puts them together into libregex.a. You can pick up either the
|
||||
library or *.o ("make lib" makes sure there are no other .o files left
|
||||
around to confuse things).
|
||||
|
||||
Main.c, debug.c, split.c are used for regression testing but are not part
|
||||
of the RE routines themselves.
|
||||
|
||||
Regex.h goes in /usr/include. All other .h files are internal only.
|
||||
--------
|
||||
@@ -0,0 +1,92 @@
|
||||
New in alpha3.4: The complex bug alluded to below has been fixed (in a
|
||||
slightly kludgey temporary way that may hurt efficiency a bit; this is
|
||||
another "get it out the door for 4.4" release). The tests at the end of
|
||||
the tests file have accordingly been uncommented. The primary sign of
|
||||
the bug was that something like a?b matching ab matched b rather than ab.
|
||||
(The bug was essentially specific to this exact situation, else it would
|
||||
have shown up earlier.)
|
||||
|
||||
New in alpha3.3: The definition of word boundaries has been altered
|
||||
slightly, to more closely match the usual programming notion that "_"
|
||||
is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir,
|
||||
and the makefile no longer alludes to it in mysterious ways. The
|
||||
makefile has generally been cleaned up some. Fixes have been made
|
||||
(again!) so that the regression test will run without -DREDEBUG, at
|
||||
the cost of weaker checking. A workaround for a bug in some folks'
|
||||
<assert.h> has been added. And some more things have been added to
|
||||
tests, including a couple right at the end which are commented out
|
||||
because the code currently flunks them (complex bug; fix coming).
|
||||
Plus the usual minor cleanup.
|
||||
|
||||
New in alpha3.2: Assorted bits of cleanup and portability improvement
|
||||
(the development base is now a BSDI system using GCC instead of an ancient
|
||||
Sun system, and the newer compiler exposed some glitches). Fix for a
|
||||
serious bug that affected REs using many [] (including REG_ICASE REs
|
||||
because of the way they are implemented), *sometimes*, depending on
|
||||
memory-allocation patterns. The header-file prototypes no longer name
|
||||
the parameters, avoiding possible name conflicts. The possibility that
|
||||
some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is
|
||||
now handled gracefully. "uchar" is no longer used as an internal type
|
||||
name (too many people have the same idea). Still the same old lousy
|
||||
performance, alas.
|
||||
|
||||
New in alpha3.1: Basically nothing, this release is just a bookkeeping
|
||||
convenience. Stay tuned.
|
||||
|
||||
New in alpha3.0: Performance is no better, alas, but some fixes have been
|
||||
made and some functionality has been added. (This is basically the "get
|
||||
it out the door in time for 4.4" release.) One bug fix: regfree() didn't
|
||||
free the main internal structure (how embarrassing). It is now possible
|
||||
to put NULs in either the RE or the target string, using (resp.) a new
|
||||
REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to
|
||||
regcomp() makes all characters ordinary, so you can match a literal
|
||||
string easily (this will become more useful when performance improves!).
|
||||
There are now primitives to match beginnings and ends of words, although
|
||||
the syntax is disgusting and so is the implementation. The REG_ATOI
|
||||
debugging interface has changed a bit. And there has been considerable
|
||||
internal cleanup of various kinds.
|
||||
|
||||
New in alpha2.3: Split change list out of README, and moved flags notes
|
||||
into Makefile. Macro-ized the name of regex(7) in regex(3), since it has
|
||||
to change for 4.4BSD. Cleanup work in engine.c, and some new regression
|
||||
tests to catch tricky cases thereof.
|
||||
|
||||
New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two
|
||||
small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges
|
||||
in my own test program and might be useful to others for similar purposes.
|
||||
The regression test will now compile (and run) without REDEBUG. The
|
||||
BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now.
|
||||
Char/uchar parameters are now written int/unsigned, to avoid possible
|
||||
portability problems with unpromoted parameters. Some unsigned casts have
|
||||
been introduced to minimize portability problems with shifting into sign
|
||||
bits.
|
||||
|
||||
New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big
|
||||
thing is that regex.h is now generated, using mkh, rather than being
|
||||
supplied in the distribution; due to circularities in dependencies,
|
||||
you have to build regex.h explicitly by "make h". The two known bugs
|
||||
have been fixed (and the regression test now checks for them), as has a
|
||||
problem with assertions not being suppressed in the absence of REDEBUG.
|
||||
No performance work yet.
|
||||
|
||||
New in alpha2: Backslash-anything is an ordinary character, not an
|
||||
error (except, of course, for the handful of backslashed metacharacters
|
||||
in BREs), which should reduce script breakage. The regression test
|
||||
checks *where* null strings are supposed to match, and has generally
|
||||
been tightened up somewhat. Small bug fixes in parameter passing (not
|
||||
harmful, but technically errors) and some other areas. Debugging
|
||||
invoked by defining REDEBUG rather than not defining NDEBUG.
|
||||
|
||||
New in alpha+3: full prototyping for internal routines, using a little
|
||||
helper program, mkh, which extracts prototypes given in stylized comments.
|
||||
More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple
|
||||
pre-screening of input when a literal string is known to be part of the
|
||||
RE; this does wonders for performance.
|
||||
|
||||
New in alpha+2: minor bits of cleanup. Notably, the number "32" for the
|
||||
word width isn't hardwired into regexec.c any more, the public header
|
||||
file prototypes the functions if __STDC__ is defined, and some small typos
|
||||
in the manpages have been fixed.
|
||||
|
||||
New in alpha+1: improvements to the manual pages, and an important
|
||||
extension, the REG_STARTEND option to regexec().
|
||||
@@ -0,0 +1,30 @@
|
||||
/* character-class table */
|
||||
static struct cclass {
|
||||
unsigned char *name;
|
||||
unsigned char *chars;
|
||||
unsigned char *multis;
|
||||
} cclasses[] = {
|
||||
{"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""},
|
||||
{"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
||||
""},
|
||||
{"blank", " \t", ""},
|
||||
{"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
|
||||
\25\26\27\30\31\32\33\34\35\36\37\177", ""},
|
||||
{"digit", "0123456789", ""},
|
||||
{"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
|
||||
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
|
||||
""},
|
||||
{"lower", "abcdefghijklmnopqrstuvwxyz",
|
||||
""},
|
||||
{"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
|
||||
0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
|
||||
""},
|
||||
{"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
|
||||
""},
|
||||
{"space", "\t\n\v\f\r ", ""},
|
||||
{"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
""},
|
||||
{"xdigit", "0123456789ABCDEFabcdef",
|
||||
""},
|
||||
{NULL, 0, ""}
|
||||
};
|
||||
@@ -0,0 +1,102 @@
|
||||
/* character-name table */
|
||||
static struct cname {
|
||||
char *name;
|
||||
char code;
|
||||
} cnames[] = {
|
||||
{"NUL", '\0'},
|
||||
{"SOH", '\001'},
|
||||
{"STX", '\002'},
|
||||
{"ETX", '\003'},
|
||||
{"EOT", '\004'},
|
||||
{"ENQ", '\005'},
|
||||
{"ACK", '\006'},
|
||||
{"BEL", '\007'},
|
||||
{"alert", '\007'},
|
||||
{"BS", '\010'},
|
||||
{"backspace", '\b'},
|
||||
{"HT", '\011'},
|
||||
{"tab", '\t'},
|
||||
{"LF", '\012'},
|
||||
{"newline", '\n'},
|
||||
{"VT", '\013'},
|
||||
{"vertical-tab", '\v'},
|
||||
{"FF", '\014'},
|
||||
{"form-feed", '\f'},
|
||||
{"CR", '\015'},
|
||||
{"carriage-return", '\r'},
|
||||
{"SO", '\016'},
|
||||
{"SI", '\017'},
|
||||
{"DLE", '\020'},
|
||||
{"DC1", '\021'},
|
||||
{"DC2", '\022'},
|
||||
{"DC3", '\023'},
|
||||
{"DC4", '\024'},
|
||||
{"NAK", '\025'},
|
||||
{"SYN", '\026'},
|
||||
{"ETB", '\027'},
|
||||
{"CAN", '\030'},
|
||||
{"EM", '\031'},
|
||||
{"SUB", '\032'},
|
||||
{"ESC", '\033'},
|
||||
{"IS4", '\034'},
|
||||
{"FS", '\034'},
|
||||
{"IS3", '\035'},
|
||||
{"GS", '\035'},
|
||||
{"IS2", '\036'},
|
||||
{"RS", '\036'},
|
||||
{"IS1", '\037'},
|
||||
{"US", '\037'},
|
||||
{"space", ' '},
|
||||
{"exclamation-mark", '!'},
|
||||
{"quotation-mark", '"'},
|
||||
{"number-sign", '#'},
|
||||
{"dollar-sign", '$'},
|
||||
{"percent-sign", '%'},
|
||||
{"ampersand", '&'},
|
||||
{"apostrophe", '\''},
|
||||
{"left-parenthesis", '('},
|
||||
{"right-parenthesis", ')'},
|
||||
{"asterisk", '*'},
|
||||
{"plus-sign", '+'},
|
||||
{"comma", ','},
|
||||
{"hyphen", '-'},
|
||||
{"hyphen-minus", '-'},
|
||||
{"period", '.'},
|
||||
{"full-stop", '.'},
|
||||
{"slash", '/'},
|
||||
{"solidus", '/'},
|
||||
{"zero", '0'},
|
||||
{"one", '1'},
|
||||
{"two", '2'},
|
||||
{"three", '3'},
|
||||
{"four", '4'},
|
||||
{"five", '5'},
|
||||
{"six", '6'},
|
||||
{"seven", '7'},
|
||||
{"eight", '8'},
|
||||
{"nine", '9'},
|
||||
{"colon", ':'},
|
||||
{"semicolon", ';'},
|
||||
{"less-than-sign", '<'},
|
||||
{"equals-sign", '='},
|
||||
{"greater-than-sign", '>'},
|
||||
{"question-mark", '?'},
|
||||
{"commercial-at", '@'},
|
||||
{"left-square-bracket", '['},
|
||||
{"backslash", '\\'},
|
||||
{"reverse-solidus", '\\'},
|
||||
{"right-square-bracket", ']'},
|
||||
{"circumflex", '^'},
|
||||
{"circumflex-accent", '^'},
|
||||
{"underscore", '_'},
|
||||
{"low-line", '_'},
|
||||
{"grave-accent", '`'},
|
||||
{"left-brace", '{'},
|
||||
{"left-curly-bracket", '{'},
|
||||
{"vertical-line", '|'},
|
||||
{"right-brace", '}'},
|
||||
{"right-curly-bracket", '}'},
|
||||
{"tilde", '~'},
|
||||
{"DEL", '\177'},
|
||||
{NULL, 0},
|
||||
};
|
||||
@@ -0,0 +1,242 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "regex2.h"
|
||||
#include "debug.ih"
|
||||
|
||||
/*
|
||||
- regprint - print a regexp for debugging
|
||||
== void regprint(regex_t *r, FILE *d);
|
||||
*/
|
||||
void
|
||||
regprint(r, d)
|
||||
regex_t *r;
|
||||
FILE *d;
|
||||
{
|
||||
register struct re_guts *g = r->re_g;
|
||||
register int i;
|
||||
register int c;
|
||||
register int last;
|
||||
int nincat[NC];
|
||||
|
||||
fprintf(d, "%ld states, %d categories", (long)g->nstates,
|
||||
g->ncategories);
|
||||
fprintf(d, ", first %ld last %ld", (long)g->firststate,
|
||||
(long)g->laststate);
|
||||
if (g->iflags&USEBOL)
|
||||
fprintf(d, ", USEBOL");
|
||||
if (g->iflags&USEEOL)
|
||||
fprintf(d, ", USEEOL");
|
||||
if (g->iflags&BAD)
|
||||
fprintf(d, ", BAD");
|
||||
if (g->nsub > 0)
|
||||
fprintf(d, ", nsub=%ld", (long)g->nsub);
|
||||
if (g->must != NULL)
|
||||
fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
|
||||
g->must);
|
||||
if (g->backrefs)
|
||||
fprintf(d, ", backrefs");
|
||||
if (g->nplus > 0)
|
||||
fprintf(d, ", nplus %ld", (long)g->nplus);
|
||||
fprintf(d, "\n");
|
||||
s_print(g, d);
|
||||
for (i = 0; i < g->ncategories; i++) {
|
||||
nincat[i] = 0;
|
||||
for (c = CHAR_MIN; c <= CHAR_MAX; c++)
|
||||
if (g->categories[c] == i)
|
||||
nincat[i]++;
|
||||
}
|
||||
fprintf(d, "cc0#%d", nincat[0]);
|
||||
for (i = 1; i < g->ncategories; i++)
|
||||
if (nincat[i] == 1) {
|
||||
for (c = CHAR_MIN; c <= CHAR_MAX; c++)
|
||||
if (g->categories[c] == i)
|
||||
break;
|
||||
fprintf(d, ", %d=%s", i, regchar(c));
|
||||
}
|
||||
fprintf(d, "\n");
|
||||
for (i = 1; i < g->ncategories; i++)
|
||||
if (nincat[i] != 1) {
|
||||
fprintf(d, "cc%d\t", i);
|
||||
last = -1;
|
||||
for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
|
||||
if (c <= CHAR_MAX && g->categories[c] == i) {
|
||||
if (last < 0) {
|
||||
fprintf(d, "%s", regchar(c));
|
||||
last = c;
|
||||
}
|
||||
} else {
|
||||
if (last >= 0) {
|
||||
if (last != c-1)
|
||||
fprintf(d, "-%s",
|
||||
regchar(c-1));
|
||||
last = -1;
|
||||
}
|
||||
}
|
||||
fprintf(d, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- s_print - print the strip for debugging
|
||||
== static void s_print(register struct re_guts *g, FILE *d);
|
||||
*/
|
||||
static void
|
||||
s_print(g, d)
|
||||
register struct re_guts *g;
|
||||
FILE *d;
|
||||
{
|
||||
register sop *s;
|
||||
register cset *cs;
|
||||
register int i;
|
||||
register int done = 0;
|
||||
register sop opnd;
|
||||
register int col = 0;
|
||||
register int last;
|
||||
register sopno offset = 2;
|
||||
# define GAP() { if (offset % 5 == 0) { \
|
||||
if (col > 40) { \
|
||||
fprintf(d, "\n\t"); \
|
||||
col = 0; \
|
||||
} else { \
|
||||
fprintf(d, " "); \
|
||||
col++; \
|
||||
} \
|
||||
} else \
|
||||
col++; \
|
||||
offset++; \
|
||||
}
|
||||
|
||||
if (OP(g->strip[0]) != OEND)
|
||||
fprintf(d, "missing initial OEND!\n");
|
||||
for (s = &g->strip[1]; !done; s++) {
|
||||
opnd = OPND(*s);
|
||||
switch (OP(*s)) {
|
||||
case OEND:
|
||||
fprintf(d, "\n");
|
||||
done = 1;
|
||||
break;
|
||||
case OCHAR:
|
||||
if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
|
||||
fprintf(d, "\\%c", (unsigned char)opnd);
|
||||
else
|
||||
fprintf(d, "%s", regchar((unsigned char)opnd));
|
||||
break;
|
||||
case OBOL:
|
||||
fprintf(d, "^");
|
||||
break;
|
||||
case OEOL:
|
||||
fprintf(d, "$");
|
||||
break;
|
||||
case OBOW:
|
||||
fprintf(d, "\\{");
|
||||
break;
|
||||
case OEOW:
|
||||
fprintf(d, "\\}");
|
||||
break;
|
||||
case OANY:
|
||||
fprintf(d, ".");
|
||||
break;
|
||||
case OANYOF:
|
||||
fprintf(d, "[(%ld)", (long)opnd);
|
||||
cs = &g->sets[opnd];
|
||||
last = -1;
|
||||
for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
|
||||
if (CHIN(cs, i) && i < g->csetsize) {
|
||||
if (last < 0) {
|
||||
fprintf(d, "%s", regchar(i));
|
||||
last = i;
|
||||
}
|
||||
} else {
|
||||
if (last >= 0) {
|
||||
if (last != i-1)
|
||||
fprintf(d, "-%s",
|
||||
regchar(i-1));
|
||||
last = -1;
|
||||
}
|
||||
}
|
||||
fprintf(d, "]");
|
||||
break;
|
||||
case OBACK_:
|
||||
fprintf(d, "(\\<%ld>", (long)opnd);
|
||||
break;
|
||||
case O_BACK:
|
||||
fprintf(d, "<%ld>\\)", (long)opnd);
|
||||
break;
|
||||
case OPLUS_:
|
||||
fprintf(d, "(+");
|
||||
if (OP(*(s+opnd)) != O_PLUS)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
break;
|
||||
case O_PLUS:
|
||||
if (OP(*(s-opnd)) != OPLUS_)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
fprintf(d, "+)");
|
||||
break;
|
||||
case OQUEST_:
|
||||
fprintf(d, "(?");
|
||||
if (OP(*(s+opnd)) != O_QUEST)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
break;
|
||||
case O_QUEST:
|
||||
if (OP(*(s-opnd)) != OQUEST_)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
fprintf(d, "?)");
|
||||
break;
|
||||
case OLPAREN:
|
||||
fprintf(d, "((<%ld>", (long)opnd);
|
||||
break;
|
||||
case ORPAREN:
|
||||
fprintf(d, "<%ld>))", (long)opnd);
|
||||
break;
|
||||
case OCH_:
|
||||
fprintf(d, "<");
|
||||
if (OP(*(s+opnd)) != OOR2)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
break;
|
||||
case OOR1:
|
||||
if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
fprintf(d, "|");
|
||||
break;
|
||||
case OOR2:
|
||||
fprintf(d, "|");
|
||||
if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
break;
|
||||
case O_CH:
|
||||
if (OP(*(s-opnd)) != OOR1)
|
||||
fprintf(d, "<%ld>", (long)opnd);
|
||||
fprintf(d, ">");
|
||||
break;
|
||||
default:
|
||||
fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
|
||||
break;
|
||||
}
|
||||
if (!done)
|
||||
GAP();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- regchar - make a character printable
|
||||
== static char *regchar(int ch);
|
||||
*/
|
||||
static unsigned char * /* -> representation */
|
||||
regchar(ch)
|
||||
int ch;
|
||||
{
|
||||
static unsigned char buf[10];
|
||||
|
||||
if (isprint(ch) || ch == ' ')
|
||||
sprintf(buf, "%c", ch);
|
||||
else
|
||||
sprintf(buf, "\\%o", ch);
|
||||
return(buf);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/* ========= begin header generated by ./mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === debug.c === */
|
||||
void regprint(regex_t *r, FILE *d);
|
||||
static void s_print(register struct re_guts *g, FILE *d);
|
||||
static char *regchar(int ch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ./mkh ========= */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,35 @@
|
||||
/* ========= begin header generated by ./mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === engine.c === */
|
||||
static int matcher(register struct re_guts *g, unsigned char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
|
||||
static unsigned char *dissect(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst);
|
||||
static unsigned char *backref(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst, sopno lev);
|
||||
static unsigned char *fast(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst);
|
||||
static unsigned char *slow(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst);
|
||||
static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft);
|
||||
#define BOL (OUT+1)
|
||||
#define EOL (BOL+1)
|
||||
#define BOLEOL (BOL+2)
|
||||
#define NOTHING (BOL+3)
|
||||
#define BOW (BOL+4)
|
||||
#define EOW (BOL+5)
|
||||
#define CODEMAX (BOL+5) /* highest code used */
|
||||
#define NONCHAR(c) ((c) > UCHAR_MAX)
|
||||
#define NNONCHAR (CODEMAX-UCHAR_MAX)
|
||||
#ifdef REDEBUG
|
||||
static void print(struct match *m, unsigned char *caption, states st, int ch, FILE *d);
|
||||
#endif
|
||||
#ifdef REDEBUG
|
||||
static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst);
|
||||
#endif
|
||||
#ifdef REDEBUG
|
||||
static unsigned char *pchar(int ch);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ./mkh ========= */
|
||||
@@ -0,0 +1,510 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "main.ih"
|
||||
|
||||
char *progname;
|
||||
int debug = 0;
|
||||
int line = 0;
|
||||
int status = 0;
|
||||
|
||||
int copts = REG_EXTENDED;
|
||||
int eopts = 0;
|
||||
regoff_t startoff = 0;
|
||||
regoff_t endoff = 0;
|
||||
|
||||
|
||||
extern int split();
|
||||
extern void regprint();
|
||||
|
||||
/*
|
||||
- main - do the simple case, hand off to regress() for regression
|
||||
*/
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
regex_t re;
|
||||
# define NS 10
|
||||
regmatch_t subs[NS];
|
||||
char erbuf[100];
|
||||
int err;
|
||||
size_t len;
|
||||
int c;
|
||||
int errflg = 0;
|
||||
register int i;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF)
|
||||
switch (c) {
|
||||
case 'c': /* compile options */
|
||||
copts = options('c', optarg);
|
||||
break;
|
||||
case 'e': /* execute options */
|
||||
eopts = options('e', optarg);
|
||||
break;
|
||||
case 'S': /* start offset */
|
||||
startoff = (regoff_t)atoi(optarg);
|
||||
break;
|
||||
case 'E': /* end offset */
|
||||
endoff = (regoff_t)atoi(optarg);
|
||||
break;
|
||||
case 'x': /* Debugging. */
|
||||
debug++;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
errflg++;
|
||||
break;
|
||||
}
|
||||
if (errflg) {
|
||||
fprintf(stderr, "usage: %s ", progname);
|
||||
fprintf(stderr, "[-c copt][-C][-d] [re]\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (optind >= argc) {
|
||||
regress(stdin);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
err = regcomp(&re, argv[optind++], copts);
|
||||
if (err) {
|
||||
len = regerror(err, &re, erbuf, sizeof(erbuf));
|
||||
fprintf(stderr, "error %s, %d/%d `%s'\n",
|
||||
eprint(err), len, sizeof(erbuf), erbuf);
|
||||
exit(status);
|
||||
}
|
||||
regprint(&re, stdout);
|
||||
|
||||
if (optind >= argc) {
|
||||
regfree(&re);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
if (eopts®_STARTEND) {
|
||||
subs[0].rm_so = startoff;
|
||||
subs[0].rm_eo = strlen(argv[optind]) - endoff;
|
||||
}
|
||||
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
|
||||
if (err) {
|
||||
len = regerror(err, &re, erbuf, sizeof(erbuf));
|
||||
fprintf(stderr, "error %s, %d/%d `%s'\n",
|
||||
eprint(err), len, sizeof(erbuf), erbuf);
|
||||
exit(status);
|
||||
}
|
||||
if (!(copts®_NOSUB)) {
|
||||
len = (int)(subs[0].rm_eo - subs[0].rm_so);
|
||||
if (subs[0].rm_so != -1) {
|
||||
if (len != 0)
|
||||
printf("match `%.*s'\n", (int)len,
|
||||
argv[optind] + subs[0].rm_so);
|
||||
else
|
||||
printf("match `'@%.1s\n",
|
||||
argv[optind] + subs[0].rm_so);
|
||||
}
|
||||
for (i = 1; i < NS; i++)
|
||||
if (subs[i].rm_so != -1)
|
||||
printf("(%d) `%.*s'\n", i,
|
||||
(int)(subs[i].rm_eo - subs[i].rm_so),
|
||||
argv[optind] + subs[i].rm_so);
|
||||
}
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
- regress - main loop of regression test
|
||||
== void regress(FILE *in);
|
||||
*/
|
||||
void
|
||||
regress(in)
|
||||
FILE *in;
|
||||
{
|
||||
char inbuf[1000];
|
||||
# define MAXF 10
|
||||
char *f[MAXF];
|
||||
int nf;
|
||||
int i;
|
||||
char erbuf[100];
|
||||
size_t ne;
|
||||
char *badpat = "invalid regular expression";
|
||||
# define SHORT 10
|
||||
char *bpname = "REG_BADPAT";
|
||||
regex_t re;
|
||||
|
||||
while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
|
||||
line++;
|
||||
if (inbuf[0] == '#' || inbuf[0] == '\n')
|
||||
continue; /* NOTE CONTINUE */
|
||||
inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */
|
||||
if (debug)
|
||||
fprintf(stdout, "%d:\n", line);
|
||||
nf = split(inbuf, f, MAXF, "\t\t");
|
||||
if (nf < 3) {
|
||||
fprintf(stderr, "bad input, line %d\n", line);
|
||||
exit(1);
|
||||
}
|
||||
for (i = 0; i < nf; i++)
|
||||
if (strcmp(f[i], "\"\"") == 0)
|
||||
f[i] = "";
|
||||
if (nf <= 3)
|
||||
f[3] = NULL;
|
||||
if (nf <= 4)
|
||||
f[4] = NULL;
|
||||
try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
|
||||
if (opt('&', f[1])) /* try with either type of RE */
|
||||
try(f[0], f[1], f[2], f[3], f[4],
|
||||
options('c', f[1]) &~ REG_EXTENDED);
|
||||
}
|
||||
|
||||
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
|
||||
if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
|
||||
fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
|
||||
erbuf, badpat);
|
||||
status = 1;
|
||||
}
|
||||
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
|
||||
if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
|
||||
ne != strlen(badpat)+1) {
|
||||
fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
|
||||
erbuf, SHORT-1, badpat);
|
||||
status = 1;
|
||||
}
|
||||
ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
|
||||
if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
|
||||
fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
|
||||
erbuf, bpname);
|
||||
status = 1;
|
||||
}
|
||||
re.re_endp = bpname;
|
||||
ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
|
||||
if (atoi(erbuf) != (int)REG_BADPAT) {
|
||||
fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
|
||||
erbuf, (long)REG_BADPAT);
|
||||
status = 1;
|
||||
} else if (ne != strlen(erbuf)+1) {
|
||||
fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
|
||||
erbuf, (long)REG_BADPAT);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- try - try it, and report on problems
|
||||
== void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
|
||||
*/
|
||||
void
|
||||
try(f0, f1, f2, f3, f4, opts)
|
||||
char *f0;
|
||||
char *f1;
|
||||
char *f2;
|
||||
char *f3;
|
||||
char *f4;
|
||||
int opts; /* may not match f1 */
|
||||
{
|
||||
regex_t re;
|
||||
# define NSUBS 10
|
||||
regmatch_t subs[NSUBS];
|
||||
# define NSHOULD 15
|
||||
char *should[NSHOULD];
|
||||
int nshould;
|
||||
char erbuf[100];
|
||||
int err;
|
||||
int len;
|
||||
char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
|
||||
register int i;
|
||||
char *grump;
|
||||
char f0copy[1000];
|
||||
char f2copy[1000];
|
||||
|
||||
strcpy(f0copy, f0);
|
||||
re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL;
|
||||
fixstr(f0copy);
|
||||
err = regcomp(&re, f0copy, opts);
|
||||
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
|
||||
/* unexpected error or wrong error */
|
||||
len = regerror(err, &re, erbuf, sizeof(erbuf));
|
||||
fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
|
||||
line, type, eprint(err), len,
|
||||
sizeof(erbuf), erbuf);
|
||||
status = 1;
|
||||
} else if (err == 0 && opt('C', f1)) {
|
||||
/* unexpected success */
|
||||
fprintf(stderr, "%d: %s should have given REG_%s\n",
|
||||
line, type, f2);
|
||||
status = 1;
|
||||
err = 1; /* so we won't try regexec */
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
regfree(&re);
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(f2copy, f2);
|
||||
fixstr(f2copy);
|
||||
|
||||
if (options('e', f1)®_STARTEND) {
|
||||
if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
|
||||
fprintf(stderr, "%d: bad STARTEND syntax\n", line);
|
||||
subs[0].rm_so = strchr(f2, '(') - f2 + 1;
|
||||
subs[0].rm_eo = strchr(f2, ')') - f2;
|
||||
}
|
||||
err = regexec(&re, f2copy, NSUBS, subs, options('e', f1));
|
||||
|
||||
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
|
||||
/* unexpected error or wrong error */
|
||||
len = regerror(err, &re, erbuf, sizeof(erbuf));
|
||||
fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
|
||||
line, type, eprint(err), len,
|
||||
sizeof(erbuf), erbuf);
|
||||
status = 1;
|
||||
} else if (err != 0) {
|
||||
/* nothing more to check */
|
||||
} else if (f3 == NULL) {
|
||||
/* unexpected success */
|
||||
fprintf(stderr, "%d: %s exec should have failed\n",
|
||||
line, type);
|
||||
status = 1;
|
||||
err = 1; /* just on principle */
|
||||
} else if (opts®_NOSUB) {
|
||||
/* nothing more to check */
|
||||
} else if ((grump = check(f2, subs[0], f3)) != NULL) {
|
||||
fprintf(stderr, "%d: %s %s\n", line, type, grump);
|
||||
status = 1;
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if (err != 0 || f4 == NULL) {
|
||||
regfree(&re);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 1; i < NSHOULD; i++)
|
||||
should[i] = NULL;
|
||||
nshould = split(f4, should+1, NSHOULD-1, ",");
|
||||
if (nshould == 0) {
|
||||
nshould = 1;
|
||||
should[1] = "";
|
||||
}
|
||||
for (i = 1; i < NSUBS; i++) {
|
||||
grump = check(f2, subs[i], should[i]);
|
||||
if (grump != NULL) {
|
||||
fprintf(stderr, "%d: %s $%d %s\n", line,
|
||||
type, i, grump);
|
||||
status = 1;
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
regfree(&re);
|
||||
}
|
||||
|
||||
/*
|
||||
- options - pick options out of a regression-test string
|
||||
== int options(int type, char *s);
|
||||
*/
|
||||
int
|
||||
options(type, s)
|
||||
int type; /* 'c' compile, 'e' exec */
|
||||
char *s;
|
||||
{
|
||||
register char *p;
|
||||
register int o = (type == 'c') ? copts : eopts;
|
||||
register char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
|
||||
|
||||
for (p = s; *p != '\0'; p++)
|
||||
if (strchr(legal, *p) != NULL)
|
||||
switch (*p) {
|
||||
case 'b':
|
||||
o &= ~REG_EXTENDED;
|
||||
break;
|
||||
case 'i':
|
||||
o |= REG_ICASE;
|
||||
break;
|
||||
case 's':
|
||||
o |= REG_NOSUB;
|
||||
break;
|
||||
case 'n':
|
||||
o |= REG_NEWLINE;
|
||||
break;
|
||||
case 'm':
|
||||
o &= ~REG_EXTENDED;
|
||||
o |= REG_NOSPEC;
|
||||
break;
|
||||
case 'p':
|
||||
o |= REG_PEND;
|
||||
break;
|
||||
case '^':
|
||||
o |= REG_NOTBOL;
|
||||
break;
|
||||
case '$':
|
||||
o |= REG_NOTEOL;
|
||||
break;
|
||||
case '#':
|
||||
o |= REG_STARTEND;
|
||||
break;
|
||||
case 't': /* trace */
|
||||
o |= REG_TRACE;
|
||||
break;
|
||||
case 'l': /* force long representation */
|
||||
o |= REG_LARGE;
|
||||
break;
|
||||
case 'r': /* force backref use */
|
||||
o |= REG_BACKR;
|
||||
break;
|
||||
}
|
||||
return(o);
|
||||
}
|
||||
|
||||
/*
|
||||
- opt - is a particular option in a regression string?
|
||||
== int opt(int c, char *s);
|
||||
*/
|
||||
int /* predicate */
|
||||
opt(c, s)
|
||||
int c;
|
||||
char *s;
|
||||
{
|
||||
return(strchr(s, c) != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
- fixstr - transform magic characters in strings
|
||||
== void fixstr(register char *p);
|
||||
*/
|
||||
void
|
||||
fixstr(p)
|
||||
register char *p;
|
||||
{
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
for (; *p != '\0'; p++)
|
||||
if (*p == 'N')
|
||||
*p = '\n';
|
||||
else if (*p == 'T')
|
||||
*p = '\t';
|
||||
else if (*p == 'S')
|
||||
*p = ' ';
|
||||
else if (*p == 'Z')
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
- check - check a substring match
|
||||
== char *check(char *str, regmatch_t sub, char *should);
|
||||
*/
|
||||
char * /* NULL or complaint */
|
||||
check(str, sub, should)
|
||||
char *str;
|
||||
regmatch_t sub;
|
||||
char *should;
|
||||
{
|
||||
register int len;
|
||||
register int shlen;
|
||||
register char *p;
|
||||
static char grump[500];
|
||||
register char *at = NULL;
|
||||
|
||||
if (should != NULL && strcmp(should, "-") == 0)
|
||||
should = NULL;
|
||||
if (should != NULL && should[0] == '@') {
|
||||
at = should + 1;
|
||||
should = "";
|
||||
}
|
||||
|
||||
/* check rm_so and rm_eo for consistency */
|
||||
if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) ||
|
||||
(sub.rm_so != -1 && sub.rm_eo == -1) ||
|
||||
(sub.rm_so != -1 && sub.rm_so < 0) ||
|
||||
(sub.rm_eo != -1 && sub.rm_eo < 0) ) {
|
||||
sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
|
||||
(long)sub.rm_eo);
|
||||
return(grump);
|
||||
}
|
||||
|
||||
/* check for no match */
|
||||
if (sub.rm_so == -1 && should == NULL)
|
||||
return(NULL);
|
||||
if (sub.rm_so == -1)
|
||||
return("did not match");
|
||||
|
||||
/* check for in range */
|
||||
if (sub.rm_eo > strlen(str)) {
|
||||
sprintf(grump, "start %ld end %ld, past end of string",
|
||||
(long)sub.rm_so, (long)sub.rm_eo);
|
||||
return(grump);
|
||||
}
|
||||
|
||||
len = (int)(sub.rm_eo - sub.rm_so);
|
||||
shlen = (int)strlen(should);
|
||||
p = str + sub.rm_so;
|
||||
|
||||
/* check for not supposed to match */
|
||||
if (should == NULL) {
|
||||
sprintf(grump, "matched `%.*s'", len, p);
|
||||
return(grump);
|
||||
}
|
||||
|
||||
/* check for wrong match */
|
||||
if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
|
||||
sprintf(grump, "matched `%.*s' instead", len, p);
|
||||
return(grump);
|
||||
}
|
||||
if (shlen > 0)
|
||||
return(NULL);
|
||||
|
||||
/* check null match in right place */
|
||||
if (at == NULL)
|
||||
return(NULL);
|
||||
shlen = strlen(at);
|
||||
if (shlen == 0)
|
||||
shlen = 1; /* force check for end-of-string */
|
||||
if (strncmp(p, at, shlen) != 0) {
|
||||
sprintf(grump, "matched null at `%.20s'", p);
|
||||
return(grump);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
- eprint - convert error number to name
|
||||
== static char *eprint(int err);
|
||||
*/
|
||||
static char *
|
||||
eprint(err)
|
||||
int err;
|
||||
{
|
||||
static char epbuf[100];
|
||||
size_t len;
|
||||
|
||||
len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
|
||||
assert(len <= sizeof(epbuf));
|
||||
return(epbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
- efind - convert error name to number
|
||||
== static int efind(char *name);
|
||||
*/
|
||||
static int
|
||||
efind(name)
|
||||
char *name;
|
||||
{
|
||||
static char efbuf[100];
|
||||
regex_t re;
|
||||
|
||||
sprintf(efbuf, "REG_%s", name);
|
||||
assert(strlen(efbuf) < sizeof(efbuf));
|
||||
re.re_endp = efbuf;
|
||||
(void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
|
||||
return(atoi(efbuf));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/* ========= begin header generated by ./mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === main.c === */
|
||||
void regress(FILE *in);
|
||||
void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
|
||||
int options(int type, char *s);
|
||||
int opt(int c, char *s);
|
||||
void fixstr(register char *p);
|
||||
char *check(char *str, regmatch_t sub, char *should);
|
||||
static char *eprint(int err);
|
||||
static int efind(char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ./mkh ========= */
|
||||
@@ -0,0 +1,76 @@
|
||||
#! /bin/sh
|
||||
# mkh - pull headers out of C source
|
||||
PATH=/bin:/usr/bin ; export PATH
|
||||
|
||||
# egrep pattern to pick out marked lines
|
||||
egrep='^ =([ ]|$)'
|
||||
|
||||
# Sed program to process marked lines into lines for the header file.
|
||||
# The markers have already been removed. Two things are done here: removal
|
||||
# of backslashed newlines, and some fudging of comments. The first is done
|
||||
# because -o needs to have prototypes on one line to strip them down.
|
||||
# Getting comments into the output is tricky; we turn C++-style // comments
|
||||
# into /* */ comments, after altering any existing */'s to avoid trouble.
|
||||
peel=' /\\$/N
|
||||
/\\\n[ ]*/s///g
|
||||
/\/\//s;\*/;* /;g
|
||||
/\/\//s;//\(.*\);/*\1 */;'
|
||||
|
||||
for a
|
||||
do
|
||||
case "$a" in
|
||||
-o) # old (pre-function-prototype) compiler
|
||||
# add code to comment out argument lists
|
||||
peel="$peel
|
||||
"'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
|
||||
shift
|
||||
;;
|
||||
-b) # funny Berkeley __P macro
|
||||
peel="$peel
|
||||
"'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
|
||||
shift
|
||||
;;
|
||||
-s) # compiler doesn't like `static foo();'
|
||||
# add code to get rid of the `static'
|
||||
peel="$peel
|
||||
"'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
|
||||
shift
|
||||
;;
|
||||
-p) # private declarations
|
||||
egrep='^ ==([ ]|$)'
|
||||
shift
|
||||
;;
|
||||
-i) # wrap in #ifndef, argument is name
|
||||
ifndef="$2"
|
||||
shift ; shift
|
||||
;;
|
||||
*) break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test " $ifndef" != " "
|
||||
then
|
||||
echo "#ifndef $ifndef"
|
||||
echo "#define $ifndef /* never again */"
|
||||
fi
|
||||
echo "/* ========= begin header generated by $0 ========= */"
|
||||
echo '#ifdef __cplusplus'
|
||||
echo 'extern "C" {'
|
||||
echo '#endif'
|
||||
for f
|
||||
do
|
||||
echo
|
||||
echo "/* === $f === */"
|
||||
egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
|
||||
echo
|
||||
done
|
||||
echo '#ifdef __cplusplus'
|
||||
echo '}'
|
||||
echo '#endif'
|
||||
echo "/* ========= end header generated by $0 ========= */"
|
||||
if test " $ifndef" != " "
|
||||
then
|
||||
echo "#endif"
|
||||
fi
|
||||
exit 0
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,53 @@
|
||||
/* ========= begin header generated by ./mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === regcomp.c === */
|
||||
static void p_ere(register struct parse *p, int stop);
|
||||
static void p_ere_exp(register struct parse *p);
|
||||
static void p_str(register struct parse *p);
|
||||
static void p_bre(register struct parse *p, register int end1, register int end2);
|
||||
static int p_simp_re(register struct parse *p, int starordinary);
|
||||
static int p_count(register struct parse *p);
|
||||
static void p_bracket(register struct parse *p);
|
||||
static void p_b_term(register struct parse *p, register cset *cs);
|
||||
static void p_b_cclass(register struct parse *p, register cset *cs);
|
||||
static void p_b_eclass(register struct parse *p, register cset *cs);
|
||||
static unsigned char p_b_symbol(register struct parse *p);
|
||||
static unsigned char p_b_coll_elem(register struct parse *p, int endc);
|
||||
static unsigned char othercase(int ch);
|
||||
static void bothcases(register struct parse *p, int ch);
|
||||
static void ordinary(register struct parse *p, register int ch);
|
||||
static void nonnewline(register struct parse *p);
|
||||
static void repeat(register struct parse *p, sopno start, int from, int to);
|
||||
static int seterr(register struct parse *p, int e);
|
||||
static cset *allocset(register struct parse *p);
|
||||
static void freeset(register struct parse *p, register cset *cs);
|
||||
static int freezeset(register struct parse *p, register cset *cs);
|
||||
static int firstch(register struct parse *p, register cset *cs);
|
||||
static int nch(register struct parse *p, register cset *cs);
|
||||
static void mcadd(register struct parse *p, register cset *cs, register unsigned char *cp);
|
||||
#if 0
|
||||
static void mcsub(register cset *cs, register unsigned char *cp);
|
||||
static int mcin(register cset *cs, register unsigned char *cp);
|
||||
static unsigned char *mcfind(register cset *cs, register unsigned char *cp);
|
||||
#endif
|
||||
static void mcinvert(register struct parse *p, register cset *cs);
|
||||
static void mccase(register struct parse *p, register cset *cs);
|
||||
static int isinsets(register struct re_guts *g, int c);
|
||||
static int samesets(register struct re_guts *g, int c1, int c2);
|
||||
static void categorize(struct parse *p, register struct re_guts *g);
|
||||
static sopno dupl(register struct parse *p, sopno start, sopno finish);
|
||||
static void doemit(register struct parse *p, sop op, size_t opnd);
|
||||
static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
|
||||
static void dofwd(register struct parse *p, sopno pos, sop value);
|
||||
static void enlarge(register struct parse *p, sopno size);
|
||||
static void stripsnug(register struct parse *p, register struct re_guts *g);
|
||||
static void findmust(register struct parse *p, register struct re_guts *g);
|
||||
static sopno pluscount(register struct parse *p, register struct re_guts *g);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ./mkh ========= */
|
||||
@@ -0,0 +1,126 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "regerror.ih"
|
||||
|
||||
/*
|
||||
= #define REG_OKAY 0
|
||||
= #define REG_NOMATCH 1
|
||||
= #define REG_BADPAT 2
|
||||
= #define REG_ECOLLATE 3
|
||||
= #define REG_ECTYPE 4
|
||||
= #define REG_EESCAPE 5
|
||||
= #define REG_ESUBREG 6
|
||||
= #define REG_EBRACK 7
|
||||
= #define REG_EPAREN 8
|
||||
= #define REG_EBRACE 9
|
||||
= #define REG_BADBR 10
|
||||
= #define REG_ERANGE 11
|
||||
= #define REG_ESPACE 12
|
||||
= #define REG_BADRPT 13
|
||||
= #define REG_EMPTY 14
|
||||
= #define REG_ASSERT 15
|
||||
= #define REG_INVARG 16
|
||||
= #define REG_ATOI 255 // convert name to number (!)
|
||||
= #define REG_ITOA 0400 // convert number to name (!)
|
||||
*/
|
||||
static struct rerr {
|
||||
int code;
|
||||
char *name;
|
||||
char *explain;
|
||||
} rerrs[] = {
|
||||
{REG_OKAY, "REG_OKAY", "no errors detected"},
|
||||
{REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"},
|
||||
{REG_BADPAT, "REG_BADPAT", "invalid regular expression"},
|
||||
{REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element"},
|
||||
{REG_ECTYPE, "REG_ECTYPE", "invalid character class"},
|
||||
{REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)"},
|
||||
{REG_ESUBREG, "REG_ESUBREG", "invalid backreference number"},
|
||||
{REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced"},
|
||||
{REG_EPAREN, "REG_EPAREN", "parentheses not balanced"},
|
||||
{REG_EBRACE, "REG_EBRACE", "braces not balanced"},
|
||||
{REG_BADBR, "REG_BADBR", "invalid repetition count(s)"},
|
||||
{REG_ERANGE, "REG_ERANGE", "invalid character range"},
|
||||
{REG_ESPACE, "REG_ESPACE", "out of memory"},
|
||||
{REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid"},
|
||||
{REG_EMPTY, "REG_EMPTY", "empty (sub)expression"},
|
||||
{REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug"},
|
||||
{REG_INVARG, "REG_INVARG", "invalid argument to regex routine"},
|
||||
{-1, "", "*** unknown regexp error code ***"},
|
||||
};
|
||||
|
||||
/*
|
||||
- regerror - the interface to error numbers
|
||||
= API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
API_EXPORT(size_t)
|
||||
regerror(errcode, preg, errbuf, errbuf_size)
|
||||
int errcode;
|
||||
const regex_t *preg;
|
||||
char *errbuf;
|
||||
size_t errbuf_size;
|
||||
{
|
||||
register struct rerr *r;
|
||||
register size_t len;
|
||||
register int target = errcode &~ REG_ITOA;
|
||||
register char *s;
|
||||
char convbuf[50];
|
||||
|
||||
if (errcode == REG_ATOI)
|
||||
s = regatoi(preg, convbuf);
|
||||
else {
|
||||
for (r = rerrs; r->code >= 0; r++)
|
||||
if (r->code == target)
|
||||
break;
|
||||
|
||||
if (errcode®_ITOA) {
|
||||
if (r->code >= 0)
|
||||
(void) strcpy(convbuf, r->name);
|
||||
else
|
||||
sprintf(convbuf, "REG_0x%x", target);
|
||||
assert(strlen(convbuf) < sizeof(convbuf));
|
||||
s = convbuf;
|
||||
} else
|
||||
s = r->explain;
|
||||
}
|
||||
|
||||
len = strlen(s) + 1;
|
||||
if (errbuf_size > 0) {
|
||||
if (errbuf_size > len)
|
||||
(void) strcpy(errbuf, s);
|
||||
else {
|
||||
(void) strncpy(errbuf, s, errbuf_size-1);
|
||||
errbuf[errbuf_size-1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
/*
|
||||
- regatoi - internal routine to implement REG_ATOI
|
||||
== static char *regatoi(const regex_t *preg, char *localbuf);
|
||||
*/
|
||||
static char *
|
||||
regatoi(preg, localbuf)
|
||||
const regex_t *preg;
|
||||
char *localbuf;
|
||||
{
|
||||
register struct rerr *r;
|
||||
|
||||
for (r = rerrs; r->code >= 0; r++)
|
||||
if (strcmp(r->name, preg->re_endp) == 0)
|
||||
break;
|
||||
if (r->code < 0)
|
||||
return("0");
|
||||
|
||||
sprintf(localbuf, "%d", r->code);
|
||||
return(localbuf);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/* ========= begin header generated by ./mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === regerror.c === */
|
||||
static char *regatoi(const regex_t *preg, char *localbuf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ./mkh ========= */
|
||||
@@ -0,0 +1,502 @@
|
||||
.TH REGEX 3 "17 May 1993"
|
||||
.BY "Henry Spencer"
|
||||
.de ZR
|
||||
.\" one other place knows this name: the SEE ALSO section
|
||||
.IR regex (7) \\$1
|
||||
..
|
||||
.SH NAME
|
||||
regcomp, regexec, regerror, regfree \- regular-expression library
|
||||
.SH SYNOPSIS
|
||||
.ft B
|
||||
.\".na
|
||||
#include <sys/types.h>
|
||||
.br
|
||||
#include <regex.h>
|
||||
.HP 10
|
||||
int regcomp(regex_t\ *preg, const\ char\ *pattern, int\ cflags);
|
||||
.HP
|
||||
int\ regexec(const\ regex_t\ *preg, const\ char\ *string,
|
||||
size_t\ nmatch, regmatch_t\ pmatch[], int\ eflags);
|
||||
.HP
|
||||
size_t\ regerror(int\ errcode, const\ regex_t\ *preg,
|
||||
char\ *errbuf, size_t\ errbuf_size);
|
||||
.HP
|
||||
void\ regfree(regex_t\ *preg);
|
||||
.\".ad
|
||||
.ft
|
||||
.SH DESCRIPTION
|
||||
These routines implement POSIX 1003.2 regular expressions (``RE''s);
|
||||
see
|
||||
.ZR .
|
||||
.I Regcomp
|
||||
compiles an RE written as a string into an internal form,
|
||||
.I regexec
|
||||
matches that internal form against a string and reports results,
|
||||
.I regerror
|
||||
transforms error codes from either into human-readable messages,
|
||||
and
|
||||
.I regfree
|
||||
frees any dynamically-allocated storage used by the internal form
|
||||
of an RE.
|
||||
.PP
|
||||
The header
|
||||
.I <regex.h>
|
||||
declares two structure types,
|
||||
.I regex_t
|
||||
and
|
||||
.IR regmatch_t ,
|
||||
the former for compiled internal forms and the latter for match reporting.
|
||||
It also declares the four functions,
|
||||
a type
|
||||
.IR regoff_t ,
|
||||
and a number of constants with names starting with ``REG_''.
|
||||
.PP
|
||||
.I Regcomp
|
||||
compiles the regular expression contained in the
|
||||
.I pattern
|
||||
string,
|
||||
subject to the flags in
|
||||
.IR cflags ,
|
||||
and places the results in the
|
||||
.I regex_t
|
||||
structure pointed to by
|
||||
.IR preg .
|
||||
.I Cflags
|
||||
is the bitwise OR of zero or more of the following flags:
|
||||
.IP REG_EXTENDED \w'REG_EXTENDED'u+2n
|
||||
Compile modern (``extended'') REs,
|
||||
rather than the obsolete (``basic'') REs that
|
||||
are the default.
|
||||
.IP REG_BASIC
|
||||
This is a synonym for 0,
|
||||
provided as a counterpart to REG_EXTENDED to improve readability.
|
||||
.IP REG_NOSPEC
|
||||
Compile with recognition of all special characters turned off.
|
||||
All characters are thus considered ordinary,
|
||||
so the ``RE'' is a literal string.
|
||||
This is an extension,
|
||||
compatible with but not specified by POSIX 1003.2,
|
||||
and should be used with
|
||||
caution in software intended to be portable to other systems.
|
||||
REG_EXTENDED and REG_NOSPEC may not be used
|
||||
in the same call to
|
||||
.IR regcomp .
|
||||
.IP REG_ICASE
|
||||
Compile for matching that ignores upper/lower case distinctions.
|
||||
See
|
||||
.ZR .
|
||||
.IP REG_NOSUB
|
||||
Compile for matching that need only report success or failure,
|
||||
not what was matched.
|
||||
.IP REG_NEWLINE
|
||||
Compile for newline-sensitive matching.
|
||||
By default, newline is a completely ordinary character with no special
|
||||
meaning in either REs or strings.
|
||||
With this flag,
|
||||
`[^' bracket expressions and `.' never match newline,
|
||||
a `^' anchor matches the null string after any newline in the string
|
||||
in addition to its normal function,
|
||||
and the `$' anchor matches the null string before any newline in the
|
||||
string in addition to its normal function.
|
||||
.IP REG_PEND
|
||||
The regular expression ends,
|
||||
not at the first NUL,
|
||||
but just before the character pointed to by the
|
||||
.I re_endp
|
||||
member of the structure pointed to by
|
||||
.IR preg .
|
||||
The
|
||||
.I re_endp
|
||||
member is of type
|
||||
.IR const\ char\ * .
|
||||
This flag permits inclusion of NULs in the RE;
|
||||
they are considered ordinary characters.
|
||||
This is an extension,
|
||||
compatible with but not specified by POSIX 1003.2,
|
||||
and should be used with
|
||||
caution in software intended to be portable to other systems.
|
||||
.PP
|
||||
When successful,
|
||||
.I regcomp
|
||||
returns 0 and fills in the structure pointed to by
|
||||
.IR preg .
|
||||
One member of that structure
|
||||
(other than
|
||||
.IR re_endp )
|
||||
is publicized:
|
||||
.IR re_nsub ,
|
||||
of type
|
||||
.IR size_t ,
|
||||
contains the number of parenthesized subexpressions within the RE
|
||||
(except that the value of this member is undefined if the
|
||||
REG_NOSUB flag was used).
|
||||
If
|
||||
.I regcomp
|
||||
fails, it returns a non-zero error code;
|
||||
see DIAGNOSTICS.
|
||||
.PP
|
||||
.I Regexec
|
||||
matches the compiled RE pointed to by
|
||||
.I preg
|
||||
against the
|
||||
.IR string ,
|
||||
subject to the flags in
|
||||
.IR eflags ,
|
||||
and reports results using
|
||||
.IR nmatch ,
|
||||
.IR pmatch ,
|
||||
and the returned value.
|
||||
The RE must have been compiled by a previous invocation of
|
||||
.IR regcomp .
|
||||
The compiled form is not altered during execution of
|
||||
.IR regexec ,
|
||||
so a single compiled RE can be used simultaneously by multiple threads.
|
||||
.PP
|
||||
By default,
|
||||
the NUL-terminated string pointed to by
|
||||
.I string
|
||||
is considered to be the text of an entire line, minus any terminating
|
||||
newline.
|
||||
The
|
||||
.I eflags
|
||||
argument is the bitwise OR of zero or more of the following flags:
|
||||
.IP REG_NOTBOL \w'REG_STARTEND'u+2n
|
||||
The first character of
|
||||
the string
|
||||
is not the beginning of a line, so the `^' anchor should not match before it.
|
||||
This does not affect the behavior of newlines under REG_NEWLINE.
|
||||
.IP REG_NOTEOL
|
||||
The NUL terminating
|
||||
the string
|
||||
does not end a line, so the `$' anchor should not match before it.
|
||||
This does not affect the behavior of newlines under REG_NEWLINE.
|
||||
.IP REG_STARTEND
|
||||
The string is considered to start at
|
||||
\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR
|
||||
and to have a terminating NUL located at
|
||||
\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR
|
||||
(there need not actually be a NUL at that location),
|
||||
regardless of the value of
|
||||
.IR nmatch .
|
||||
See below for the definition of
|
||||
.IR pmatch
|
||||
and
|
||||
.IR nmatch .
|
||||
This is an extension,
|
||||
compatible with but not specified by POSIX 1003.2,
|
||||
and should be used with
|
||||
caution in software intended to be portable to other systems.
|
||||
Note that a non-zero \fIrm_so\fR does not imply REG_NOTBOL;
|
||||
REG_STARTEND affects only the location of the string,
|
||||
not how it is matched.
|
||||
.PP
|
||||
See
|
||||
.ZR
|
||||
for a discussion of what is matched in situations where an RE or a
|
||||
portion thereof could match any of several substrings of
|
||||
.IR string .
|
||||
.PP
|
||||
Normally,
|
||||
.I regexec
|
||||
returns 0 for success and the non-zero code REG_NOMATCH for failure.
|
||||
Other non-zero error codes may be returned in exceptional situations;
|
||||
see DIAGNOSTICS.
|
||||
.PP
|
||||
If REG_NOSUB was specified in the compilation of the RE,
|
||||
or if
|
||||
.I nmatch
|
||||
is 0,
|
||||
.I regexec
|
||||
ignores the
|
||||
.I pmatch
|
||||
argument (but see below for the case where REG_STARTEND is specified).
|
||||
Otherwise,
|
||||
.I pmatch
|
||||
points to an array of
|
||||
.I nmatch
|
||||
structures of type
|
||||
.IR regmatch_t .
|
||||
Such a structure has at least the members
|
||||
.I rm_so
|
||||
and
|
||||
.IR rm_eo ,
|
||||
both of type
|
||||
.I regoff_t
|
||||
(a signed arithmetic type at least as large as an
|
||||
.I off_t
|
||||
and a
|
||||
.IR ssize_t ),
|
||||
containing respectively the offset of the first character of a substring
|
||||
and the offset of the first character after the end of the substring.
|
||||
Offsets are measured from the beginning of the
|
||||
.I string
|
||||
argument given to
|
||||
.IR regexec .
|
||||
An empty substring is denoted by equal offsets,
|
||||
both indicating the character following the empty substring.
|
||||
.PP
|
||||
The 0th member of the
|
||||
.I pmatch
|
||||
array is filled in to indicate what substring of
|
||||
.I string
|
||||
was matched by the entire RE.
|
||||
Remaining members report what substring was matched by parenthesized
|
||||
subexpressions within the RE;
|
||||
member
|
||||
.I i
|
||||
reports subexpression
|
||||
.IR i ,
|
||||
with subexpressions counted (starting at 1) by the order of their opening
|
||||
parentheses in the RE, left to right.
|
||||
Unused entries in the array\(emcorresponding either to subexpressions that
|
||||
did not participate in the match at all, or to subexpressions that do not
|
||||
exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both
|
||||
.I rm_so
|
||||
and
|
||||
.I rm_eo
|
||||
set to \-1.
|
||||
If a subexpression participated in the match several times,
|
||||
the reported substring is the last one it matched.
|
||||
(Note, as an example in particular, that when the RE `(b*)+' matches `bbb',
|
||||
the parenthesized subexpression matches each of the three `b's and then
|
||||
an infinite number of empty strings following the last `b',
|
||||
so the reported substring is one of the empties.)
|
||||
.PP
|
||||
If REG_STARTEND is specified,
|
||||
.I pmatch
|
||||
must point to at least one
|
||||
.I regmatch_t
|
||||
(even if
|
||||
.I nmatch
|
||||
is 0 or REG_NOSUB was specified),
|
||||
to hold the input offsets for REG_STARTEND.
|
||||
Use for output is still entirely controlled by
|
||||
.IR nmatch ;
|
||||
if
|
||||
.I nmatch
|
||||
is 0 or REG_NOSUB was specified,
|
||||
the value of
|
||||
.IR pmatch [0]
|
||||
will not be changed by a successful
|
||||
.IR regexec .
|
||||
.PP
|
||||
.I Regerror
|
||||
maps a non-zero
|
||||
.I errcode
|
||||
from either
|
||||
.I regcomp
|
||||
or
|
||||
.I regexec
|
||||
to a human-readable, printable message.
|
||||
If
|
||||
.I preg
|
||||
is non-NULL,
|
||||
the error code should have arisen from use of
|
||||
the
|
||||
.I regex_t
|
||||
pointed to by
|
||||
.IR preg ,
|
||||
and if the error code came from
|
||||
.IR regcomp ,
|
||||
it should have been the result from the most recent
|
||||
.I regcomp
|
||||
using that
|
||||
.IR regex_t .
|
||||
.RI ( Regerror
|
||||
may be able to supply a more detailed message using information
|
||||
from the
|
||||
.IR regex_t .)
|
||||
.I Regerror
|
||||
places the NUL-terminated message into the buffer pointed to by
|
||||
.IR errbuf ,
|
||||
limiting the length (including the NUL) to at most
|
||||
.I errbuf_size
|
||||
bytes.
|
||||
If the whole message won't fit,
|
||||
as much of it as will fit before the terminating NUL is supplied.
|
||||
In any case,
|
||||
the returned value is the size of buffer needed to hold the whole
|
||||
message (including terminating NUL).
|
||||
If
|
||||
.I errbuf_size
|
||||
is 0,
|
||||
.I errbuf
|
||||
is ignored but the return value is still correct.
|
||||
.PP
|
||||
If the
|
||||
.I errcode
|
||||
given to
|
||||
.I regerror
|
||||
is first ORed with REG_ITOA,
|
||||
the ``message'' that results is the printable name of the error code,
|
||||
e.g. ``REG_NOMATCH'',
|
||||
rather than an explanation thereof.
|
||||
If
|
||||
.I errcode
|
||||
is REG_ATOI,
|
||||
then
|
||||
.I preg
|
||||
shall be non-NULL and the
|
||||
.I re_endp
|
||||
member of the structure it points to
|
||||
must point to the printable name of an error code;
|
||||
in this case, the result in
|
||||
.I errbuf
|
||||
is the decimal digits of
|
||||
the numeric value of the error code
|
||||
(0 if the name is not recognized).
|
||||
REG_ITOA and REG_ATOI are intended primarily as debugging facilities;
|
||||
they are extensions,
|
||||
compatible with but not specified by POSIX 1003.2,
|
||||
and should be used with
|
||||
caution in software intended to be portable to other systems.
|
||||
Be warned also that they are considered experimental and changes are possible.
|
||||
.PP
|
||||
.I Regfree
|
||||
frees any dynamically-allocated storage associated with the compiled RE
|
||||
pointed to by
|
||||
.IR preg .
|
||||
The remaining
|
||||
.I regex_t
|
||||
is no longer a valid compiled RE
|
||||
and the effect of supplying it to
|
||||
.I regexec
|
||||
or
|
||||
.I regerror
|
||||
is undefined.
|
||||
.PP
|
||||
None of these functions references global variables except for tables
|
||||
of constants;
|
||||
all are safe for use from multiple threads if the arguments are safe.
|
||||
.SH IMPLEMENTATION CHOICES
|
||||
There are a number of decisions that 1003.2 leaves up to the implementor,
|
||||
either by explicitly saying ``undefined'' or by virtue of them being
|
||||
forbidden by the RE grammar.
|
||||
This implementation treats them as follows.
|
||||
.PP
|
||||
See
|
||||
.ZR
|
||||
for a discussion of the definition of case-independent matching.
|
||||
.PP
|
||||
There is no particular limit on the length of REs,
|
||||
except insofar as memory is limited.
|
||||
Memory usage is approximately linear in RE size, and largely insensitive
|
||||
to RE complexity, except for bounded repetitions.
|
||||
See BUGS for one short RE using them
|
||||
that will run almost any system out of memory.
|
||||
.PP
|
||||
A backslashed character other than one specifically given a magic meaning
|
||||
by 1003.2 (such magic meanings occur only in obsolete [``basic''] REs)
|
||||
is taken as an ordinary character.
|
||||
.PP
|
||||
Any unmatched [ is a REG_EBRACK error.
|
||||
.PP
|
||||
Equivalence classes cannot begin or end bracket-expression ranges.
|
||||
The endpoint of one range cannot begin another.
|
||||
.PP
|
||||
RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
|
||||
.PP
|
||||
A repetition operator (?, *, +, or bounds) cannot follow another
|
||||
repetition operator.
|
||||
A repetition operator cannot begin an expression or subexpression
|
||||
or follow `^' or `|'.
|
||||
.PP
|
||||
`|' cannot appear first or last in a (sub)expression or after another `|',
|
||||
i.e. an operand of `|' cannot be an empty subexpression.
|
||||
An empty parenthesized subexpression, `()', is legal and matches an
|
||||
empty (sub)string.
|
||||
An empty string is not a legal RE.
|
||||
.PP
|
||||
A `{' followed by a digit is considered the beginning of bounds for a
|
||||
bounded repetition, which must then follow the syntax for bounds.
|
||||
A `{' \fInot\fR followed by a digit is considered an ordinary character.
|
||||
.PP
|
||||
`^' and `$' beginning and ending subexpressions in obsolete (``basic'')
|
||||
REs are anchors, not ordinary characters.
|
||||
.SH SEE ALSO
|
||||
grep(1), regex(7)
|
||||
.PP
|
||||
POSIX 1003.2, sections 2.8 (Regular Expression Notation)
|
||||
and
|
||||
B.5 (C Binding for Regular Expression Matching).
|
||||
.SH DIAGNOSTICS
|
||||
Non-zero error codes from
|
||||
.I regcomp
|
||||
and
|
||||
.I regexec
|
||||
include the following:
|
||||
.PP
|
||||
.nf
|
||||
.ta \w'REG_ECOLLATE'u+3n
|
||||
REG_NOMATCH regexec() failed to match
|
||||
REG_BADPAT invalid regular expression
|
||||
REG_ECOLLATE invalid collating element
|
||||
REG_ECTYPE invalid character class
|
||||
REG_EESCAPE \e applied to unescapable character
|
||||
REG_ESUBREG invalid backreference number
|
||||
REG_EBRACK brackets [ ] not balanced
|
||||
REG_EPAREN parentheses ( ) not balanced
|
||||
REG_EBRACE braces { } not balanced
|
||||
REG_BADBR invalid repetition count(s) in { }
|
||||
REG_ERANGE invalid character range in [ ]
|
||||
REG_ESPACE ran out of memory
|
||||
REG_BADRPT ?, *, or + operand invalid
|
||||
REG_EMPTY empty (sub)expression
|
||||
REG_ASSERT ``can't happen''\(emyou found a bug
|
||||
REG_INVARG invalid argument, e.g. negative-length string
|
||||
.fi
|
||||
.SH HISTORY
|
||||
Written by Henry Spencer at University of Toronto,
|
||||
henry@zoo.toronto.edu.
|
||||
.SH BUGS
|
||||
This is an alpha release with known defects.
|
||||
Please report problems.
|
||||
.PP
|
||||
There is one known functionality bug.
|
||||
The implementation of internationalization is incomplete:
|
||||
the locale is always assumed to be the default one of 1003.2,
|
||||
and only the collating elements etc. of that locale are available.
|
||||
.PP
|
||||
The back-reference code is subtle and doubts linger about its correctness
|
||||
in complex cases.
|
||||
.PP
|
||||
.I Regexec
|
||||
performance is poor.
|
||||
This will improve with later releases.
|
||||
.I Nmatch
|
||||
exceeding 0 is expensive;
|
||||
.I nmatch
|
||||
exceeding 1 is worse.
|
||||
.I Regexec
|
||||
is largely insensitive to RE complexity \fIexcept\fR that back
|
||||
references are massively expensive.
|
||||
RE length does matter; in particular, there is a strong speed bonus
|
||||
for keeping RE length under about 30 characters,
|
||||
with most special characters counting roughly double.
|
||||
.PP
|
||||
.I Regcomp
|
||||
implements bounded repetitions by macro expansion,
|
||||
which is costly in time and space if counts are large
|
||||
or bounded repetitions are nested.
|
||||
An RE like, say,
|
||||
`((((a{1,100}){1,100}){1,100}){1,100}){1,100}'
|
||||
will (eventually) run almost any existing machine out of swap space.
|
||||
.PP
|
||||
There are suspected problems with response to obscure error conditions.
|
||||
Notably,
|
||||
certain kinds of internal overflow,
|
||||
produced only by truly enormous REs or by multiply nested bounded repetitions,
|
||||
are probably not handled well.
|
||||
.PP
|
||||
Due to a mistake in 1003.2, things like `a)b' are legal REs because `)' is
|
||||
a special character only in the presence of a previous unmatched `('.
|
||||
This can't be fixed until the spec is fixed.
|
||||
.PP
|
||||
The standard's definition of back references is vague.
|
||||
For example, does
|
||||
`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?
|
||||
Until the standard is clarified,
|
||||
behavior in such cases should not be relied on.
|
||||
.PP
|
||||
The implementation of word-boundary matching is a bit of a kludge,
|
||||
and bugs may lurk in combinations of word-boundary matching and anchoring.
|
||||
@@ -0,0 +1,233 @@
|
||||
.TH REGEX 7 "7 Feb 1994"
|
||||
.BY "Henry Spencer"
|
||||
.SH NAME
|
||||
regex \- POSIX 1003.2 regular expressions
|
||||
.SH DESCRIPTION
|
||||
Regular expressions (``RE''s),
|
||||
as defined in POSIX 1003.2, come in two forms:
|
||||
modern REs (roughly those of
|
||||
.IR egrep ;
|
||||
1003.2 calls these ``extended'' REs)
|
||||
and obsolete REs (roughly those of
|
||||
.IR ed ;
|
||||
1003.2 ``basic'' REs).
|
||||
Obsolete REs mostly exist for backward compatibility in some old programs;
|
||||
they will be discussed at the end.
|
||||
1003.2 leaves some aspects of RE syntax and semantics open;
|
||||
`\(dg' marks decisions on these aspects that
|
||||
may not be fully portable to other 1003.2 implementations.
|
||||
.PP
|
||||
A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR,
|
||||
separated by `|'.
|
||||
It matches anything that matches one of the branches.
|
||||
.PP
|
||||
A branch is one\(dg or more \fIpieces\fR, concatenated.
|
||||
It matches a match for the first, followed by a match for the second, etc.
|
||||
.PP
|
||||
A piece is an \fIatom\fR possibly followed
|
||||
by a single\(dg `*', `+', `?', or \fIbound\fR.
|
||||
An atom followed by `*' matches a sequence of 0 or more matches of the atom.
|
||||
An atom followed by `+' matches a sequence of 1 or more matches of the atom.
|
||||
An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
|
||||
.PP
|
||||
A \fIbound\fR is `{' followed by an unsigned decimal integer,
|
||||
possibly followed by `,'
|
||||
possibly followed by another unsigned decimal integer,
|
||||
always followed by `}'.
|
||||
The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive,
|
||||
and if there are two of them, the first may not exceed the second.
|
||||
An atom followed by a bound containing one integer \fIi\fR
|
||||
and no comma matches
|
||||
a sequence of exactly \fIi\fR matches of the atom.
|
||||
An atom followed by a bound
|
||||
containing one integer \fIi\fR and a comma matches
|
||||
a sequence of \fIi\fR or more matches of the atom.
|
||||
An atom followed by a bound
|
||||
containing two integers \fIi\fR and \fIj\fR matches
|
||||
a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
|
||||
.PP
|
||||
An atom is a regular expression enclosed in `()' (matching a match for the
|
||||
regular expression),
|
||||
an empty set of `()' (matching the null string)\(dg,
|
||||
a \fIbracket expression\fR (see below), `.'
|
||||
(matching any single character), `^' (matching the null string at the
|
||||
beginning of a line), `$' (matching the null string at the
|
||||
end of a line), a `\e' followed by one of the characters
|
||||
`^.[$()|*+?{\e'
|
||||
(matching that character taken as an ordinary character),
|
||||
a `\e' followed by any other character\(dg
|
||||
(matching that character taken as an ordinary character,
|
||||
as if the `\e' had not been present\(dg),
|
||||
or a single character with no other significance (matching that character).
|
||||
A `{' followed by a character other than a digit is an ordinary
|
||||
character, not the beginning of a bound\(dg.
|
||||
It is illegal to end an RE with `\e'.
|
||||
.PP
|
||||
A \fIbracket expression\fR is a list of characters enclosed in `[]'.
|
||||
It normally matches any single character from the list (but see below).
|
||||
If the list begins with `^',
|
||||
it matches any single character
|
||||
(but see below) \fInot\fR from the rest of the list.
|
||||
If two characters in the list are separated by `\-', this is shorthand
|
||||
for the full \fIrange\fR of characters between those two (inclusive) in the
|
||||
collating sequence,
|
||||
e.g. `[0-9]' in ASCII matches any decimal digit.
|
||||
It is illegal\(dg for two ranges to share an
|
||||
endpoint, e.g. `a-c-e'.
|
||||
Ranges are very collating-sequence-dependent,
|
||||
and portable programs should avoid relying on them.
|
||||
.PP
|
||||
To include a literal `]' in the list, make it the first character
|
||||
(following a possible `^').
|
||||
To include a literal `\-', make it the first or last character,
|
||||
or the second endpoint of a range.
|
||||
To use a literal `\-' as the first endpoint of a range,
|
||||
enclose it in `[.' and `.]' to make it a collating element (see below).
|
||||
With the exception of these and some combinations using `[' (see next
|
||||
paragraphs), all other special characters, including `\e', lose their
|
||||
special significance within a bracket expression.
|
||||
.PP
|
||||
Within a bracket expression, a collating element (a character,
|
||||
a multi-character sequence that collates as if it were a single character,
|
||||
or a collating-sequence name for either)
|
||||
enclosed in `[.' and `.]' stands for the
|
||||
sequence of characters of that collating element.
|
||||
The sequence is a single element of the bracket expression's list.
|
||||
A bracket expression containing a multi-character collating element
|
||||
can thus match more than one character,
|
||||
e.g. if the collating sequence includes a `ch' collating element,
|
||||
then the RE `[[.ch.]]*c' matches the first five characters
|
||||
of `chchcc'.
|
||||
.PP
|
||||
Within a bracket expression, a collating element enclosed in `[=' and
|
||||
`=]' is an equivalence class, standing for the sequences of characters
|
||||
of all collating elements equivalent to that one, including itself.
|
||||
(If there are no other equivalent collating elements,
|
||||
the treatment is as if the enclosing delimiters were `[.' and `.]'.)
|
||||
For example, if o and \o'o^' are the members of an equivalence class,
|
||||
then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
|
||||
An equivalence class may not\(dg be an endpoint
|
||||
of a range.
|
||||
.PP
|
||||
Within a bracket expression, the name of a \fIcharacter class\fR enclosed
|
||||
in `[:' and `:]' stands for the list of all characters belonging to that
|
||||
class.
|
||||
Standard character class names are:
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
.ta 3c 6c 9c
|
||||
alnum digit punct
|
||||
alpha graph space
|
||||
blank lower upper
|
||||
cntrl print xdigit
|
||||
.fi
|
||||
.RE
|
||||
.PP
|
||||
These stand for the character classes defined in
|
||||
.IR ctype (3).
|
||||
A locale may provide others.
|
||||
A character class may not be used as an endpoint of a range.
|
||||
.PP
|
||||
There are two special cases\(dg of bracket expressions:
|
||||
the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at
|
||||
the beginning and end of a word respectively.
|
||||
A word is defined as a sequence of
|
||||
word characters
|
||||
which is neither preceded nor followed by
|
||||
word characters.
|
||||
A word character is an
|
||||
.I alnum
|
||||
character (as defined by
|
||||
.IR ctype (3))
|
||||
or an underscore.
|
||||
This is an extension,
|
||||
compatible with but not specified by POSIX 1003.2,
|
||||
and should be used with
|
||||
caution in software intended to be portable to other systems.
|
||||
.PP
|
||||
In the event that an RE could match more than one substring of a given
|
||||
string,
|
||||
the RE matches the one starting earliest in the string.
|
||||
If the RE could match more than one substring starting at that point,
|
||||
it matches the longest.
|
||||
Subexpressions also match the longest possible substrings, subject to
|
||||
the constraint that the whole match be as long as possible,
|
||||
with subexpressions starting earlier in the RE taking priority over
|
||||
ones starting later.
|
||||
Note that higher-level subexpressions thus take priority over
|
||||
their lower-level component subexpressions.
|
||||
.PP
|
||||
Match lengths are measured in characters, not collating elements.
|
||||
A null string is considered longer than no match at all.
|
||||
For example,
|
||||
`bb*' matches the three middle characters of `abbbc',
|
||||
`(wee|week)(knights|nights)' matches all ten characters of `weeknights',
|
||||
when `(.*).*' is matched against `abc' the parenthesized subexpression
|
||||
matches all three characters, and
|
||||
when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
|
||||
subexpression match the null string.
|
||||
.PP
|
||||
If case-independent matching is specified,
|
||||
the effect is much as if all case distinctions had vanished from the
|
||||
alphabet.
|
||||
When an alphabetic that exists in multiple cases appears as an
|
||||
ordinary character outside a bracket expression, it is effectively
|
||||
transformed into a bracket expression containing both cases,
|
||||
e.g. `x' becomes `[xX]'.
|
||||
When it appears inside a bracket expression, all case counterparts
|
||||
of it are added to the bracket expression, so that (e.g.) `[x]'
|
||||
becomes `[xX]' and `[^x]' becomes `[^xX]'.
|
||||
.PP
|
||||
No particular limit is imposed on the length of REs\(dg.
|
||||
Programs intended to be portable should not employ REs longer
|
||||
than 256 bytes,
|
||||
as an implementation can refuse to accept such REs and remain
|
||||
POSIX-compliant.
|
||||
.PP
|
||||
Obsolete (``basic'') regular expressions differ in several respects.
|
||||
`|', `+', and `?' are ordinary characters and there is no equivalent
|
||||
for their functionality.
|
||||
The delimiters for bounds are `\e{' and `\e}',
|
||||
with `{' and `}' by themselves ordinary characters.
|
||||
The parentheses for nested subexpressions are `\e(' and `\e)',
|
||||
with `(' and `)' by themselves ordinary characters.
|
||||
`^' is an ordinary character except at the beginning of the
|
||||
RE or\(dg the beginning of a parenthesized subexpression,
|
||||
`$' is an ordinary character except at the end of the
|
||||
RE or\(dg the end of a parenthesized subexpression,
|
||||
and `*' is an ordinary character if it appears at the beginning of the
|
||||
RE or the beginning of a parenthesized subexpression
|
||||
(after a possible leading `^').
|
||||
Finally, there is one new type of atom, a \fIback reference\fR:
|
||||
`\e' followed by a non-zero decimal digit \fId\fR
|
||||
matches the same sequence of characters
|
||||
matched by the \fId\fRth parenthesized subexpression
|
||||
(numbering subexpressions by the positions of their opening parentheses,
|
||||
left to right),
|
||||
so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'.
|
||||
.SH SEE ALSO
|
||||
regex(3)
|
||||
.PP
|
||||
POSIX 1003.2, section 2.8 (Regular Expression Notation).
|
||||
.SH BUGS
|
||||
Having two kinds of REs is a botch.
|
||||
.PP
|
||||
The current 1003.2 spec says that `)' is an ordinary character in
|
||||
the absence of an unmatched `(';
|
||||
this was an unintentional result of a wording error,
|
||||
and change is likely.
|
||||
Avoid relying on it.
|
||||
.PP
|
||||
Back references are a dreadful botch,
|
||||
posing major problems for efficient implementations.
|
||||
They are also somewhat vaguely defined
|
||||
(does
|
||||
`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?).
|
||||
Avoid using them.
|
||||
.PP
|
||||
1003.2's specification of case-independent matching is vague.
|
||||
The ``one case implies all cases'' definition given above
|
||||
is current consensus among implementors as to the right interpretation.
|
||||
.PP
|
||||
The syntax for word boundaries is incredibly ugly.
|
||||
@@ -0,0 +1,106 @@
|
||||
# Microsoft Developer Studio Project File - Name="regex" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=regex - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "regex.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "regex - Win32 Release"
|
||||
# Name "regex - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\regcomp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\regerror.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\regexec.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\regfree.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 5.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "regex"=.\regex.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef _HSREGEX_H_
|
||||
#define _HSREGEX_H_
|
||||
#ifndef _HSREGEX_H
|
||||
#define _HSREGEX_H /* never again */
|
||||
/* ========= begin header generated by ././mkh ========= */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === regex2.h === */
|
||||
#ifdef WIN32
|
||||
#define API_EXPORT(type) __declspec(dllexport) type __stdcall
|
||||
#else
|
||||
#define API_EXPORT(type) type
|
||||
#endif
|
||||
|
||||
typedef off_t regoff_t;
|
||||
typedef struct {
|
||||
int re_magic;
|
||||
size_t re_nsub; /* number of parenthesized subexpressions */
|
||||
const char *re_endp; /* end pointer for REG_PEND */
|
||||
struct re_guts *re_g; /* none of your business :-) */
|
||||
} regex_t;
|
||||
typedef struct {
|
||||
regoff_t rm_so; /* start of match */
|
||||
regoff_t rm_eo; /* end of match */
|
||||
} regmatch_t;
|
||||
|
||||
|
||||
/* === regcomp.c === */
|
||||
API_EXPORT(int) regcomp(regex_t *, const char *, int);
|
||||
#define REG_BASIC 0000
|
||||
#define REG_EXTENDED 0001
|
||||
#define REG_ICASE 0002
|
||||
#define REG_NOSUB 0004
|
||||
#define REG_NEWLINE 0010
|
||||
#define REG_NOSPEC 0020
|
||||
#define REG_PEND 0040
|
||||
#define REG_DUMP 0200
|
||||
|
||||
|
||||
/* === regerror.c === */
|
||||
#define REG_OKAY 0
|
||||
#define REG_NOMATCH 1
|
||||
#define REG_BADPAT 2
|
||||
#define REG_ECOLLATE 3
|
||||
#define REG_ECTYPE 4
|
||||
#define REG_EESCAPE 5
|
||||
#define REG_ESUBREG 6
|
||||
#define REG_EBRACK 7
|
||||
#define REG_EPAREN 8
|
||||
#define REG_EBRACE 9
|
||||
#define REG_BADBR 10
|
||||
#define REG_ERANGE 11
|
||||
#define REG_ESPACE 12
|
||||
#define REG_BADRPT 13
|
||||
#define REG_EMPTY 14
|
||||
#define REG_ASSERT 15
|
||||
#define REG_INVARG 16
|
||||
#define REG_ATOI 255 /* convert name to number (!) */
|
||||
#define REG_ITOA 0400 /* convert number to name (!) */
|
||||
API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
|
||||
|
||||
|
||||
/* === regexec.c === */
|
||||
API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
|
||||
#define REG_NOTBOL 00001
|
||||
#define REG_NOTEOL 00002
|
||||
#define REG_STARTEND 00004
|
||||
#define REG_TRACE 00400 /* tracing of execution */
|
||||
#define REG_LARGE 01000 /* force large representation */
|
||||
#define REG_BACKR 02000 /* force use of backref code */
|
||||
|
||||
|
||||
/* === regfree.c === */
|
||||
API_EXPORT(void) regfree(regex_t *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* ========= end header generated by ././mkh ========= */
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,304 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on regex.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=regex - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to regex - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "regex - Win32 Release" && "$(CFG)" != "regex - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "regex.mak" CFG="regex - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "regex - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "regex - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\.\Release
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\regex.lib"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\regex.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\regcomp.obj"
|
||||
-@erase "$(INTDIR)\regerror.obj"
|
||||
-@erase "$(INTDIR)\regexec.obj"
|
||||
-@erase "$(INTDIR)\regfree.obj"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "$(OUTDIR)\regex.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\regcomp.obj" \
|
||||
"$(INTDIR)\regerror.obj" \
|
||||
"$(INTDIR)\regexec.obj" \
|
||||
"$(INTDIR)\regfree.obj"
|
||||
|
||||
"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\regex.lib" "$(OUTDIR)\regex.bsc"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\regcomp.obj"
|
||||
-@erase "$(INTDIR)\regcomp.sbr"
|
||||
-@erase "$(INTDIR)\regerror.obj"
|
||||
-@erase "$(INTDIR)\regerror.sbr"
|
||||
-@erase "$(INTDIR)\regexec.obj"
|
||||
-@erase "$(INTDIR)\regexec.sbr"
|
||||
-@erase "$(INTDIR)\regfree.obj"
|
||||
-@erase "$(INTDIR)\regfree.sbr"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "$(OUTDIR)\regex.bsc"
|
||||
-@erase "$(OUTDIR)\regex.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP_PROJ=/nologo /MDd /W3 /GX /Z7 /Od /I "." /D "WIN32" /D "_DEBUG" /D\
|
||||
"_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\regex.pch" /YX /Fo"$(INTDIR)\\"\
|
||||
/Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\regex.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\regcomp.sbr" \
|
||||
"$(INTDIR)\regerror.sbr" \
|
||||
"$(INTDIR)\regexec.sbr" \
|
||||
"$(INTDIR)\regfree.sbr"
|
||||
|
||||
"$(OUTDIR)\regex.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LIB32=link.exe -lib
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\regex.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\regcomp.obj" \
|
||||
"$(INTDIR)\regerror.obj" \
|
||||
"$(INTDIR)\regexec.obj" \
|
||||
"$(INTDIR)\regfree.obj"
|
||||
|
||||
"$(OUTDIR)\regex.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release" || "$(CFG)" == "regex - Win32 Debug"
|
||||
SOURCE=.\regcomp.c
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
DEP_CPP_REGCO=\
|
||||
".\cclass.h"\
|
||||
".\cname.h"\
|
||||
".\regcomp.ih"\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regcomp.obj" : $(SOURCE) $(DEP_CPP_REGCO) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
DEP_CPP_REGCO=\
|
||||
".\cclass.h"\
|
||||
".\cname.h"\
|
||||
".\regcomp.ih"\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regcomp.obj" "$(INTDIR)\regcomp.sbr" : $(SOURCE) $(DEP_CPP_REGCO)\
|
||||
"$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\regerror.c
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
DEP_CPP_REGER=\
|
||||
".\regerror.ih"\
|
||||
".\regex.h"\
|
||||
".\utils.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regerror.obj" : $(SOURCE) $(DEP_CPP_REGER) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
DEP_CPP_REGER=\
|
||||
".\regerror.ih"\
|
||||
".\regex.h"\
|
||||
".\utils.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regerror.obj" "$(INTDIR)\regerror.sbr" : $(SOURCE) $(DEP_CPP_REGER)\
|
||||
"$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\regexec.c
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
DEP_CPP_REGEX=\
|
||||
".\engine.c"\
|
||||
".\engine.ih"\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regexec.obj" : $(SOURCE) $(DEP_CPP_REGEX) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
DEP_CPP_REGEX=\
|
||||
".\engine.c"\
|
||||
".\engine.ih"\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regexec.obj" "$(INTDIR)\regexec.sbr" : $(SOURCE) $(DEP_CPP_REGEX)\
|
||||
"$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\regfree.c
|
||||
|
||||
!IF "$(CFG)" == "regex - Win32 Release"
|
||||
|
||||
DEP_CPP_REGFR=\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regfree.obj" : $(SOURCE) $(DEP_CPP_REGFR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "regex - Win32 Debug"
|
||||
|
||||
DEP_CPP_REGFR=\
|
||||
".\regex.h"\
|
||||
".\regex2.h"\
|
||||
".\utils.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\regfree.obj" "$(INTDIR)\regfree.sbr" : $(SOURCE) $(DEP_CPP_REGFR)\
|
||||
"$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\engine.c
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* First, the stuff that ends up in the outside-world include file
|
||||
= #ifdef WIN32
|
||||
= #define API_EXPORT(type) __declspec(dllexport) type __stdcall
|
||||
= #else
|
||||
= #define API_EXPORT(type) type
|
||||
= #endif
|
||||
=
|
||||
= typedef off_t regoff_t;
|
||||
= typedef struct {
|
||||
= int re_magic;
|
||||
= size_t re_nsub; // number of parenthesized subexpressions
|
||||
= const unsigned char *re_endp; // end pointer for REG_PEND
|
||||
= struct re_guts *re_g; // none of your business :-)
|
||||
= } regex_t;
|
||||
= typedef struct {
|
||||
= regoff_t rm_so; // start of match
|
||||
= regoff_t rm_eo; // end of match
|
||||
= } regmatch_t;
|
||||
*/
|
||||
/*
|
||||
* internals of regex_t
|
||||
*/
|
||||
#define MAGIC1 ((('r'^0200)<<8) | 'e')
|
||||
|
||||
/*
|
||||
* The internal representation is a *strip*, a sequence of
|
||||
* operators ending with an endmarker. (Some terminology etc. is a
|
||||
* historical relic of earlier versions which used multiple strips.)
|
||||
* Certain oddities in the representation are there to permit running
|
||||
* the machinery backwards; in particular, any deviation from sequential
|
||||
* flow must be marked at both its source and its destination. Some
|
||||
* fine points:
|
||||
*
|
||||
* - OPLUS_ and O_PLUS are *inside* the loop they create.
|
||||
* - OQUEST_ and O_QUEST are *outside* the bypass they create.
|
||||
* - OCH_ and O_CH are *outside* the multi-way branch they create, while
|
||||
* OOR1 and OOR2 are respectively the end and the beginning of one of
|
||||
* the branches. Note that there is an implicit OOR2 following OCH_
|
||||
* and an implicit OOR1 preceding O_CH.
|
||||
*
|
||||
* In state representations, an operator's bit is on to signify a state
|
||||
* immediately *preceding* "execution" of that operator.
|
||||
*/
|
||||
typedef long sop; /* strip operator */
|
||||
typedef long sopno;
|
||||
#define OPRMASK 0x7c000000
|
||||
#define OPDMASK 0x03ffffff
|
||||
#define OPSHIFT (26)
|
||||
#define OP(n) ((n)&OPRMASK)
|
||||
#define OPND(n) ((n)&OPDMASK)
|
||||
#define SOP(op, opnd) ((op)|(opnd))
|
||||
/* operators meaning operand */
|
||||
/* (back, fwd are offsets) */
|
||||
#define OEND (1<<OPSHIFT) /* endmarker - */
|
||||
#define OCHAR (2<<OPSHIFT) /* character unsigned char */
|
||||
#define OBOL (3<<OPSHIFT) /* left anchor - */
|
||||
#define OEOL (4<<OPSHIFT) /* right anchor - */
|
||||
#define OANY (5<<OPSHIFT) /* . - */
|
||||
#define OANYOF (6<<OPSHIFT) /* [...] set number */
|
||||
#define OBACK_ (7<<OPSHIFT) /* begin \d paren number */
|
||||
#define O_BACK (8<<OPSHIFT) /* end \d paren number */
|
||||
#define OPLUS_ (9<<OPSHIFT) /* + prefix fwd to suffix */
|
||||
#define O_PLUS (10<<OPSHIFT) /* + suffix back to prefix */
|
||||
#define OQUEST_ (11<<OPSHIFT) /* ? prefix fwd to suffix */
|
||||
#define O_QUEST (12<<OPSHIFT) /* ? suffix back to prefix */
|
||||
#define OLPAREN (13<<OPSHIFT) /* ( fwd to ) */
|
||||
#define ORPAREN (14<<OPSHIFT) /* ) back to ( */
|
||||
#define OCH_ (15<<OPSHIFT) /* begin choice fwd to OOR2 */
|
||||
#define OOR1 (16<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */
|
||||
#define OOR2 (17<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */
|
||||
#define O_CH (18<<OPSHIFT) /* end choice back to OOR1 */
|
||||
#define OBOW (19<<OPSHIFT) /* begin word - */
|
||||
#define OEOW (20<<OPSHIFT) /* end word - */
|
||||
|
||||
/*
|
||||
* Structure for [] character-set representation. Character sets are
|
||||
* done as bit vectors, grouped 8 to a byte vector for compactness.
|
||||
* The individual set therefore has both a pointer to the byte vector
|
||||
* and a mask to pick out the relevant bit of each byte. A hash code
|
||||
* simplifies testing whether two sets could be identical.
|
||||
*
|
||||
* This will get trickier for multicharacter collating elements. As
|
||||
* preliminary hooks for dealing with such things, we also carry along
|
||||
* a string of multi-character elements, and decide the size of the
|
||||
* vectors at run time.
|
||||
*/
|
||||
typedef struct {
|
||||
uch *ptr; /* -> uch [csetsize] */
|
||||
uch mask; /* bit within array */
|
||||
uch hash; /* hash code */
|
||||
size_t smultis;
|
||||
unsigned char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
|
||||
} cset;
|
||||
/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
|
||||
#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
|
||||
#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
|
||||
#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
|
||||
#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
|
||||
#define MCsub(p, cs, cp) mcsub(p, cs, cp)
|
||||
#define MCin(p, cs, cp) mcin(p, cs, cp)
|
||||
|
||||
/* stuff for character categories */
|
||||
typedef unsigned char cat_t;
|
||||
|
||||
/*
|
||||
* main compiled-expression structure
|
||||
*/
|
||||
struct re_guts {
|
||||
int magic;
|
||||
# define MAGIC2 ((('R'^0200)<<8)|'E')
|
||||
sop *strip; /* malloced area for strip */
|
||||
int csetsize; /* number of bits in a cset vector */
|
||||
int ncsets; /* number of csets in use */
|
||||
cset *sets; /* -> cset [ncsets] */
|
||||
uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
|
||||
int cflags; /* copy of regcomp() cflags argument */
|
||||
sopno nstates; /* = number of sops */
|
||||
sopno firststate; /* the initial OEND (normally 0) */
|
||||
sopno laststate; /* the final OEND */
|
||||
int iflags; /* internal flags */
|
||||
# define USEBOL 01 /* used ^ */
|
||||
# define USEEOL 02 /* used $ */
|
||||
# define BAD 04 /* something wrong */
|
||||
int nbol; /* number of ^ used */
|
||||
int neol; /* number of $ used */
|
||||
int ncategories; /* how many character categories */
|
||||
cat_t *categories; /* ->catspace[-UCHAR_MIN] */
|
||||
unsigned char *must; /* match must contain this string */
|
||||
int mlen; /* length of must */
|
||||
size_t nsub; /* copy of re_nsub */
|
||||
int backrefs; /* does it use back references? */
|
||||
sopno nplus; /* how deep does it nest +s? */
|
||||
/* catspace must be last */
|
||||
cat_t catspace[1]; /* actually [NC] */
|
||||
};
|
||||
|
||||
/* misc utilities */
|
||||
#define OUT (UCHAR_MAX+1) /* a non-character value */
|
||||
#define ISWORD(c) (isalnum(c) || (c) == '_')
|
||||
@@ -0,0 +1,23 @@
|
||||
/* 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
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* the outer shell of regexec()
|
||||
*
|
||||
* This file includes engine.c *twice*, after muchos fiddling with the
|
||||
* macros that code uses. This lets the same code operate on two different
|
||||
* representations for state sets.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "regex2.h"
|
||||
|
||||
static int nope = 0; /* for use in asserts; shuts lint up */
|
||||
|
||||
/* macros for manipulating states, small version */
|
||||
#define states unsigned
|
||||
#define states1 unsigned /* for later use in regexec() decision */
|
||||
#define CLEAR(v) ((v) = 0)
|
||||
#define SET0(v, n) ((v) &= ~((unsigned)1 << (n)))
|
||||
#define SET1(v, n) ((v) |= (unsigned)1 << (n))
|
||||
#define ISSET(v, n) ((v) & ((unsigned)1 << (n)))
|
||||
#define ASSIGN(d, s) ((d) = (s))
|
||||
#define EQ(a, b) ((a) == (b))
|
||||
#define STATEVARS int dummy /* dummy version */
|
||||
#define STATESETUP(m, n) /* nothing */
|
||||
#define STATETEARDOWN(m) /* nothing */
|
||||
#define SETUP(v) ((v) = 0)
|
||||
#define onestate unsigned
|
||||
#define INIT(o, n) ((o) = (unsigned)1 << (n))
|
||||
#define INC(o) ((o) <<= 1)
|
||||
#define ISSTATEIN(v, o) ((v) & (o))
|
||||
/* some abbreviations; note that some of these know variable names! */
|
||||
/* do "if I'm here, I can also be there" etc without branches */
|
||||
#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n))
|
||||
#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n))
|
||||
#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n)))
|
||||
/* function names */
|
||||
#define SNAMES /* engine.c looks after details */
|
||||
|
||||
#include "engine.c"
|
||||
|
||||
/* now undo things */
|
||||
#undef states
|
||||
#undef CLEAR
|
||||
#undef SET0
|
||||
#undef SET1
|
||||
#undef ISSET
|
||||
#undef ASSIGN
|
||||
#undef EQ
|
||||
#undef STATEVARS
|
||||
#undef STATESETUP
|
||||
#undef STATETEARDOWN
|
||||
#undef SETUP
|
||||
#undef onestate
|
||||
#undef INIT
|
||||
#undef INC
|
||||
#undef ISSTATEIN
|
||||
#undef FWD
|
||||
#undef BACK
|
||||
#undef ISSETBACK
|
||||
#undef SNAMES
|
||||
|
||||
/* macros for manipulating states, large version */
|
||||
#define states unsigned char *
|
||||
#define CLEAR(v) memset(v, 0, m->g->nstates)
|
||||
#define SET0(v, n) ((v)[n] = 0)
|
||||
#define SET1(v, n) ((v)[n] = 1)
|
||||
#define ISSET(v, n) ((v)[n])
|
||||
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
|
||||
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
|
||||
#define STATEVARS int vn; unsigned char *space
|
||||
#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
|
||||
if ((m)->space == NULL) return(REG_ESPACE); \
|
||||
(m)->vn = 0; }
|
||||
#define STATETEARDOWN(m) { free((m)->space); }
|
||||
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
|
||||
#define onestate int
|
||||
#define INIT(o, n) ((o) = (n))
|
||||
#define INC(o) ((o)++)
|
||||
#define ISSTATEIN(v, o) ((v)[o])
|
||||
/* some abbreviations; note that some of these know variable names! */
|
||||
/* do "if I'm here, I can also be there" etc without branches */
|
||||
#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
|
||||
#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
|
||||
#define ISSETBACK(v, n) ((v)[here - (n)])
|
||||
/* function names */
|
||||
#define LNAMES /* flag */
|
||||
|
||||
#include "engine.c"
|
||||
|
||||
/*
|
||||
- regexec - interface for matching
|
||||
= API_EXPORT(int) regexec(const regex_t *, const char *, size_t, \
|
||||
= regmatch_t [], int);
|
||||
= #define REG_NOTBOL 00001
|
||||
= #define REG_NOTEOL 00002
|
||||
= #define REG_STARTEND 00004
|
||||
= #define REG_TRACE 00400 // tracing of execution
|
||||
= #define REG_LARGE 01000 // force large representation
|
||||
= #define REG_BACKR 02000 // force use of backref code
|
||||
*
|
||||
* We put this here so we can exploit knowledge of the state representation
|
||||
* when choosing which matcher to call. Also, by this point the matchers
|
||||
* have been prototyped.
|
||||
*/
|
||||
API_EXPORT(int) /* 0 success, REG_NOMATCH failure */
|
||||
regexec(preg, string, nmatch, pmatch, eflags)
|
||||
const regex_t *preg;
|
||||
const char *string;
|
||||
size_t nmatch;
|
||||
regmatch_t pmatch[];
|
||||
int eflags;
|
||||
{
|
||||
register struct re_guts *g = preg->re_g;
|
||||
#ifdef REDEBUG
|
||||
# define GOODFLAGS(f) (f)
|
||||
#else
|
||||
# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
|
||||
#endif
|
||||
|
||||
if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
|
||||
return(REG_BADPAT);
|
||||
assert(!(g->iflags&BAD));
|
||||
if (g->iflags&BAD) /* backstop for no-debug case */
|
||||
return(REG_BADPAT);
|
||||
eflags = GOODFLAGS(eflags);
|
||||
|
||||
if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE))
|
||||
return(smatcher(g, (unsigned char *)string, nmatch, pmatch, eflags));
|
||||
else
|
||||
return(lmatcher(g, (unsigned char *)string, nmatch, pmatch, eflags));
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "regex2.h"
|
||||
|
||||
/*
|
||||
- regfree - free everything
|
||||
= API_EXPORT(void) regfree(regex_t *);
|
||||
*/
|
||||
API_EXPORT(void)
|
||||
regfree(preg)
|
||||
regex_t *preg;
|
||||
{
|
||||
register struct re_guts *g;
|
||||
|
||||
if (preg->re_magic != MAGIC1) /* oops */
|
||||
return; /* nice to complain, but hard */
|
||||
|
||||
g = preg->re_g;
|
||||
if (g == NULL || g->magic != MAGIC2) /* oops again */
|
||||
return;
|
||||
preg->re_magic = 0; /* mark it invalid */
|
||||
g->magic = 0; /* mark it invalid */
|
||||
|
||||
if (g->strip != NULL)
|
||||
free((char *)g->strip);
|
||||
if (g->sets != NULL)
|
||||
free((char *)g->sets);
|
||||
if (g->setbits != NULL)
|
||||
free((char *)g->setbits);
|
||||
if (g->must != NULL)
|
||||
free(g->must);
|
||||
free((char *)g);
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
- split - divide a string into fields, like awk split()
|
||||
= int split(char *string, char *fields[], int nfields, char *sep);
|
||||
*/
|
||||
int /* number of fields, including overflow */
|
||||
split(string, fields, nfields, sep)
|
||||
char *string;
|
||||
char *fields[]; /* list is not NULL-terminated */
|
||||
int nfields; /* number of entries available in fields[] */
|
||||
char *sep; /* "" white, "c" single char, "ab" [ab]+ */
|
||||
{
|
||||
register char *p = string;
|
||||
register char c; /* latest character */
|
||||
register char sepc = sep[0];
|
||||
register char sepc2;
|
||||
register int fn;
|
||||
register char **fp = fields;
|
||||
register char *sepp;
|
||||
register int trimtrail;
|
||||
|
||||
/* white space */
|
||||
if (sepc == '\0') {
|
||||
while ((c = *p++) == ' ' || c == '\t')
|
||||
continue;
|
||||
p--;
|
||||
trimtrail = 1;
|
||||
sep = " \t"; /* note, code below knows this is 2 long */
|
||||
sepc = ' ';
|
||||
} else
|
||||
trimtrail = 0;
|
||||
sepc2 = sep[1]; /* now we can safely pick this up */
|
||||
|
||||
/* catch empties */
|
||||
if (*p == '\0')
|
||||
return(0);
|
||||
|
||||
/* single separator */
|
||||
if (sepc2 == '\0') {
|
||||
fn = nfields;
|
||||
for (;;) {
|
||||
*fp++ = p;
|
||||
fn--;
|
||||
if (fn == 0)
|
||||
break;
|
||||
while ((c = *p++) != sepc)
|
||||
if (c == '\0')
|
||||
return(nfields - fn);
|
||||
*(p-1) = '\0';
|
||||
}
|
||||
/* we have overflowed the fields vector -- just count them */
|
||||
fn = nfields;
|
||||
for (;;) {
|
||||
while ((c = *p++) != sepc)
|
||||
if (c == '\0')
|
||||
return(fn);
|
||||
fn++;
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
/* two separators */
|
||||
if (sep[2] == '\0') {
|
||||
fn = nfields;
|
||||
for (;;) {
|
||||
*fp++ = p;
|
||||
fn--;
|
||||
while ((c = *p++) != sepc && c != sepc2)
|
||||
if (c == '\0') {
|
||||
if (trimtrail && **(fp-1) == '\0')
|
||||
fn++;
|
||||
return(nfields - fn);
|
||||
}
|
||||
if (fn == 0)
|
||||
break;
|
||||
*(p-1) = '\0';
|
||||
while ((c = *p++) == sepc || c == sepc2)
|
||||
continue;
|
||||
p--;
|
||||
}
|
||||
/* we have overflowed the fields vector -- just count them */
|
||||
fn = nfields;
|
||||
while (c != '\0') {
|
||||
while ((c = *p++) == sepc || c == sepc2)
|
||||
continue;
|
||||
p--;
|
||||
fn++;
|
||||
while ((c = *p++) != '\0' && c != sepc && c != sepc2)
|
||||
continue;
|
||||
}
|
||||
/* might have to trim trailing white space */
|
||||
if (trimtrail) {
|
||||
p--;
|
||||
while ((c = *--p) == sepc || c == sepc2)
|
||||
continue;
|
||||
p++;
|
||||
if (*p != '\0') {
|
||||
if (fn == nfields+1)
|
||||
*p = '\0';
|
||||
fn--;
|
||||
}
|
||||
}
|
||||
return(fn);
|
||||
}
|
||||
|
||||
/* n separators */
|
||||
fn = 0;
|
||||
for (;;) {
|
||||
if (fn < nfields)
|
||||
*fp++ = p;
|
||||
fn++;
|
||||
for (;;) {
|
||||
c = *p++;
|
||||
if (c == '\0')
|
||||
return(fn);
|
||||
sepp = sep;
|
||||
while ((sepc = *sepp++) != '\0' && sepc != c)
|
||||
continue;
|
||||
if (sepc != '\0') /* it was a separator */
|
||||
break;
|
||||
}
|
||||
if (fn < nfields)
|
||||
*(p-1) = '\0';
|
||||
for (;;) {
|
||||
c = *p++;
|
||||
sepp = sep;
|
||||
while ((sepc = *sepp++) != '\0' && sepc != c)
|
||||
continue;
|
||||
if (sepc == '\0') /* it wasn't a separator */
|
||||
break;
|
||||
}
|
||||
p--;
|
||||
}
|
||||
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
#ifdef TEST_SPLIT
|
||||
|
||||
|
||||
/*
|
||||
* test program
|
||||
* pgm runs regression
|
||||
* pgm sep splits stdin lines by sep
|
||||
* pgm str sep splits str by sep
|
||||
* pgm str sep n splits str by sep n times
|
||||
*/
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char buf[512];
|
||||
register int n;
|
||||
# define MNF 10
|
||||
char *fields[MNF];
|
||||
|
||||
if (argc > 4)
|
||||
for (n = atoi(argv[3]); n > 0; n--) {
|
||||
(void) strcpy(buf, argv[1]);
|
||||
}
|
||||
else if (argc > 3)
|
||||
for (n = atoi(argv[3]); n > 0; n--) {
|
||||
(void) strcpy(buf, argv[1]);
|
||||
(void) split(buf, fields, MNF, argv[2]);
|
||||
}
|
||||
else if (argc > 2)
|
||||
dosplit(argv[1], argv[2]);
|
||||
else if (argc > 1)
|
||||
while (fgets(buf, sizeof(buf), stdin) != NULL) {
|
||||
buf[strlen(buf)-1] = '\0'; /* stomp newline */
|
||||
dosplit(buf, argv[1]);
|
||||
}
|
||||
else
|
||||
regress();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
dosplit(string, seps)
|
||||
char *string;
|
||||
char *seps;
|
||||
{
|
||||
# define NF 5
|
||||
char *fields[NF];
|
||||
register int nf;
|
||||
|
||||
nf = split(string, fields, NF, seps);
|
||||
print(nf, NF, fields);
|
||||
}
|
||||
|
||||
print(nf, nfp, fields)
|
||||
int nf;
|
||||
int nfp;
|
||||
char *fields[];
|
||||
{
|
||||
register int fn;
|
||||
register int bound;
|
||||
|
||||
bound = (nf > nfp) ? nfp : nf;
|
||||
printf("%d:\t", nf);
|
||||
for (fn = 0; fn < bound; fn++)
|
||||
printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n");
|
||||
}
|
||||
|
||||
#define RNF 5 /* some table entries know this */
|
||||
struct {
|
||||
char *str;
|
||||
char *seps;
|
||||
int nf;
|
||||
char *fi[RNF];
|
||||
} tests[] = {
|
||||
"", " ", 0, { "" },
|
||||
" ", " ", 2, { "", "" },
|
||||
"x", " ", 1, { "x" },
|
||||
"xy", " ", 1, { "xy" },
|
||||
"x y", " ", 2, { "x", "y" },
|
||||
"abc def g ", " ", 5, { "abc", "def", "", "g", "" },
|
||||
" a bcd", " ", 4, { "", "", "a", "bcd" },
|
||||
"a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
|
||||
" a b c d ", " ", 6, { "", "a", "b", "c", "d " },
|
||||
|
||||
"", " _", 0, { "" },
|
||||
" ", " _", 2, { "", "" },
|
||||
"x", " _", 1, { "x" },
|
||||
"x y", " _", 2, { "x", "y" },
|
||||
"ab _ cd", " _", 2, { "ab", "cd" },
|
||||
" a_b c ", " _", 5, { "", "a", "b", "c", "" },
|
||||
"a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" },
|
||||
" a b c d ", " _", 6, { "", "a", "b", "c", "d " },
|
||||
|
||||
"", " _~", 0, { "" },
|
||||
" ", " _~", 2, { "", "" },
|
||||
"x", " _~", 1, { "x" },
|
||||
"x y", " _~", 2, { "x", "y" },
|
||||
"ab _~ cd", " _~", 2, { "ab", "cd" },
|
||||
" a_b c~", " _~", 5, { "", "a", "b", "c", "" },
|
||||
"a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" },
|
||||
"~a b c d ", " _~", 6, { "", "a", "b", "c", "d " },
|
||||
|
||||
"", " _~-", 0, { "" },
|
||||
" ", " _~-", 2, { "", "" },
|
||||
"x", " _~-", 1, { "x" },
|
||||
"x y", " _~-", 2, { "x", "y" },
|
||||
"ab _~- cd", " _~-", 2, { "ab", "cd" },
|
||||
" a_b c~", " _~-", 5, { "", "a", "b", "c", "" },
|
||||
"a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" },
|
||||
"~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " },
|
||||
|
||||
"", " ", 0, { "" },
|
||||
" ", " ", 2, { "", "" },
|
||||
"x", " ", 1, { "x" },
|
||||
"xy", " ", 1, { "xy" },
|
||||
"x y", " ", 2, { "x", "y" },
|
||||
"abc def g ", " ", 4, { "abc", "def", "g", "" },
|
||||
" a bcd", " ", 3, { "", "a", "bcd" },
|
||||
"a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
|
||||
" a b c d ", " ", 6, { "", "a", "b", "c", "d " },
|
||||
|
||||
"", "", 0, { "" },
|
||||
" ", "", 0, { "" },
|
||||
"x", "", 1, { "x" },
|
||||
"xy", "", 1, { "xy" },
|
||||
"x y", "", 2, { "x", "y" },
|
||||
"abc def g ", "", 3, { "abc", "def", "g" },
|
||||
"\t a bcd", "", 2, { "a", "bcd" },
|
||||
" a \tb\t c ", "", 3, { "a", "b", "c" },
|
||||
"a b c d e ", "", 5, { "a", "b", "c", "d", "e" },
|
||||
"a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" },
|
||||
" a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " },
|
||||
|
||||
NULL, NULL, 0, { NULL },
|
||||
};
|
||||
|
||||
regress()
|
||||
{
|
||||
char buf[512];
|
||||
register int n;
|
||||
char *fields[RNF+1];
|
||||
register int nf;
|
||||
register int i;
|
||||
register int printit;
|
||||
register char *f;
|
||||
|
||||
for (n = 0; tests[n].str != NULL; n++) {
|
||||
(void) strcpy(buf, tests[n].str);
|
||||
fields[RNF] = NULL;
|
||||
nf = split(buf, fields, RNF, tests[n].seps);
|
||||
printit = 0;
|
||||
if (nf != tests[n].nf) {
|
||||
printf("split `%s' by `%s' gave %d fields, not %d\n",
|
||||
tests[n].str, tests[n].seps, nf, tests[n].nf);
|
||||
printit = 1;
|
||||
} else if (fields[RNF] != NULL) {
|
||||
printf("split() went beyond array end\n");
|
||||
printit = 1;
|
||||
} else {
|
||||
for (i = 0; i < nf && i < RNF; i++) {
|
||||
f = fields[i];
|
||||
if (f == NULL)
|
||||
f = "(NULL)";
|
||||
if (strcmp(f, tests[n].fi[i]) != 0) {
|
||||
printf("split `%s' by `%s', field %d is `%s', not `%s'\n",
|
||||
tests[n].str, tests[n].seps,
|
||||
i, fields[i], tests[n].fi[i]);
|
||||
printit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (printit)
|
||||
print(nf, RNF, fields);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,475 @@
|
||||
# regular expression test set
|
||||
# Lines are at least three fields, separated by one or more tabs. "" stands
|
||||
# for an empty field. First field is an RE. Second field is flags. If
|
||||
# C flag given, regcomp() is expected to fail, and the third field is the
|
||||
# error name (minus the leading REG_).
|
||||
#
|
||||
# Otherwise it is expected to succeed, and the third field is the string to
|
||||
# try matching it against. If there is no fourth field, the match is
|
||||
# expected to fail. If there is a fourth field, it is the substring that
|
||||
# the RE is expected to match. If there is a fifth field, it is a comma-
|
||||
# separated list of what the subexpressions should match, with - indicating
|
||||
# no match for that one. In both the fourth and fifth fields, a (sub)field
|
||||
# starting with @ indicates that the (sub)expression is expected to match
|
||||
# a null string followed by the stuff after the @; this provides a way to
|
||||
# test where null strings match. The character `N' in REs and strings
|
||||
# is newline, `S' is space, `T' is tab, `Z' is NUL.
|
||||
#
|
||||
# The full list of flags:
|
||||
# - placeholder, does nothing
|
||||
# b RE is a BRE, not an ERE
|
||||
# & try it as both an ERE and a BRE
|
||||
# C regcomp() error expected, third field is error name
|
||||
# i REG_ICASE
|
||||
# m ("mundane") REG_NOSPEC
|
||||
# s REG_NOSUB (not really testable)
|
||||
# n REG_NEWLINE
|
||||
# ^ REG_NOTBOL
|
||||
# $ REG_NOTEOL
|
||||
# # REG_STARTEND (see below)
|
||||
# p REG_PEND
|
||||
#
|
||||
# For REG_STARTEND, the start/end offsets are those of the substring
|
||||
# enclosed in ().
|
||||
|
||||
# basics
|
||||
a & a a
|
||||
abc & abc abc
|
||||
abc|de - abc abc
|
||||
a|b|c - abc a
|
||||
|
||||
# parentheses and perversions thereof
|
||||
a(b)c - abc abc
|
||||
a\(b\)c b abc abc
|
||||
a( C EPAREN
|
||||
a( b a( a(
|
||||
a\( - a( a(
|
||||
a\( bC EPAREN
|
||||
a\(b bC EPAREN
|
||||
a(b C EPAREN
|
||||
a(b b a(b a(b
|
||||
# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
|
||||
a) - a) a)
|
||||
) - ) )
|
||||
# end gagging (in a just world, those *should* give EPAREN)
|
||||
a) b a) a)
|
||||
a\) bC EPAREN
|
||||
\) bC EPAREN
|
||||
a()b - ab ab
|
||||
a\(\)b b ab ab
|
||||
|
||||
# anchoring and REG_NEWLINE
|
||||
^abc$ & abc abc
|
||||
a^b - a^b
|
||||
a^b b a^b a^b
|
||||
a$b - a$b
|
||||
a$b b a$b a$b
|
||||
^ & abc @abc
|
||||
$ & abc @
|
||||
^$ & "" @
|
||||
$^ - "" @
|
||||
\($\)\(^\) b "" @
|
||||
# stop retching, those are legitimate (although disgusting)
|
||||
^^ - "" @
|
||||
$$ - "" @
|
||||
b$ & abNc
|
||||
b$ &n abNc b
|
||||
^b$ & aNbNc
|
||||
^b$ &n aNbNc b
|
||||
^$ &n aNNb @Nb
|
||||
^$ n abc
|
||||
^$ n abcN @
|
||||
$^ n aNNb @Nb
|
||||
\($\)\(^\) bn aNNb @Nb
|
||||
^^ n^ aNNb @Nb
|
||||
$$ n aNNb @NN
|
||||
^a ^ a
|
||||
a$ $ a
|
||||
^a ^n aNb
|
||||
^b ^n aNb b
|
||||
a$ $n bNa
|
||||
b$ $n bNa b
|
||||
a*(^b$)c* - b b
|
||||
a*\(^b$\)c* b b b
|
||||
|
||||
# certain syntax errors and non-errors
|
||||
| C EMPTY
|
||||
| b | |
|
||||
* C BADRPT
|
||||
* b * *
|
||||
+ C BADRPT
|
||||
? C BADRPT
|
||||
"" &C EMPTY
|
||||
() - abc @abc
|
||||
\(\) b abc @abc
|
||||
a||b C EMPTY
|
||||
|ab C EMPTY
|
||||
ab| C EMPTY
|
||||
(|a)b C EMPTY
|
||||
(a|)b C EMPTY
|
||||
(*a) C BADRPT
|
||||
(+a) C BADRPT
|
||||
(?a) C BADRPT
|
||||
({1}a) C BADRPT
|
||||
\(\{1\}a\) bC BADRPT
|
||||
(a|*b) C BADRPT
|
||||
(a|+b) C BADRPT
|
||||
(a|?b) C BADRPT
|
||||
(a|{1}b) C BADRPT
|
||||
^* C BADRPT
|
||||
^* b * *
|
||||
^+ C BADRPT
|
||||
^? C BADRPT
|
||||
^{1} C BADRPT
|
||||
^\{1\} bC BADRPT
|
||||
|
||||
# metacharacters, backslashes
|
||||
a.c & abc abc
|
||||
a[bc]d & abd abd
|
||||
a\*c & a*c a*c
|
||||
a\\b & a\b a\b
|
||||
a\\\*b & a\*b a\*b
|
||||
a\bc & abc abc
|
||||
a\ &C EESCAPE
|
||||
a\\bc & a\bc a\bc
|
||||
\{ bC BADRPT
|
||||
a\[b & a[b a[b
|
||||
a[b &C EBRACK
|
||||
# trailing $ is a peculiar special case for the BRE code
|
||||
a$ & a a
|
||||
a$ & a$
|
||||
a\$ & a
|
||||
a\$ & a$ a$
|
||||
a\\$ & a
|
||||
a\\$ & a$
|
||||
a\\$ & a\$
|
||||
a\\$ & a\ a\
|
||||
|
||||
# back references, ugh
|
||||
a\(b\)\2c bC ESUBREG
|
||||
a\(b\1\)c bC ESUBREG
|
||||
a\(b*\)c\1d b abbcbbd abbcbbd bb
|
||||
a\(b*\)c\1d b abbcbd
|
||||
a\(b*\)c\1d b abbcbbbd
|
||||
^\(.\)\1 b abc
|
||||
a\([bc]\)\1d b abcdabbd abbd b
|
||||
a\(\([bc]\)\2\)*d b abbccd abbccd
|
||||
a\(\([bc]\)\2\)*d b abbcbd
|
||||
# actually, this next one probably ought to fail, but the spec is unclear
|
||||
a\(\(b\)*\2\)*d b abbbd abbbd
|
||||
# here is a case that no NFA implementation does right
|
||||
\(ab*\)[ab]*\1 b ababaaa ababaaa a
|
||||
# check out normal matching in the presence of back refs
|
||||
\(a\)\1bcd b aabcd aabcd
|
||||
\(a\)\1bc*d b aabcd aabcd
|
||||
\(a\)\1bc*d b aabd aabd
|
||||
\(a\)\1bc*d b aabcccd aabcccd
|
||||
\(a\)\1bc*[ce]d b aabcccd aabcccd
|
||||
^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd
|
||||
|
||||
# ordinary repetitions
|
||||
ab*c & abc abc
|
||||
ab+c - abc abc
|
||||
ab?c - abc abc
|
||||
a\(*\)b b a*b a*b
|
||||
a\(**\)b b ab ab
|
||||
a\(***\)b bC BADRPT
|
||||
*a b *a *a
|
||||
**a b a a
|
||||
***a bC BADRPT
|
||||
|
||||
# the dreaded bounded repetitions
|
||||
{ & { {
|
||||
{abc & {abc {abc
|
||||
{1 C BADRPT
|
||||
{1} C BADRPT
|
||||
a{b & a{b a{b
|
||||
a{1}b - ab ab
|
||||
a\{1\}b b ab ab
|
||||
a{1,}b - ab ab
|
||||
a\{1,\}b b ab ab
|
||||
a{1,2}b - aab aab
|
||||
a\{1,2\}b b aab aab
|
||||
a{1 C EBRACE
|
||||
a\{1 bC EBRACE
|
||||
a{1a C EBRACE
|
||||
a\{1a bC EBRACE
|
||||
a{1a} C BADBR
|
||||
a\{1a\} bC BADBR
|
||||
a{,2} - a{,2} a{,2}
|
||||
a\{,2\} bC BADBR
|
||||
a{,} - a{,} a{,}
|
||||
a\{,\} bC BADBR
|
||||
a{1,x} C BADBR
|
||||
a\{1,x\} bC BADBR
|
||||
a{1,x C EBRACE
|
||||
a\{1,x bC EBRACE
|
||||
a{300} C BADBR
|
||||
a\{300\} bC BADBR
|
||||
a{1,0} C BADBR
|
||||
a\{1,0\} bC BADBR
|
||||
ab{0,0}c - abcac ac
|
||||
ab\{0,0\}c b abcac ac
|
||||
ab{0,1}c - abcac abc
|
||||
ab\{0,1\}c b abcac abc
|
||||
ab{0,3}c - abbcac abbc
|
||||
ab\{0,3\}c b abbcac abbc
|
||||
ab{1,1}c - acabc abc
|
||||
ab\{1,1\}c b acabc abc
|
||||
ab{1,3}c - acabc abc
|
||||
ab\{1,3\}c b acabc abc
|
||||
ab{2,2}c - abcabbc abbc
|
||||
ab\{2,2\}c b abcabbc abbc
|
||||
ab{2,4}c - abcabbc abbc
|
||||
ab\{2,4\}c b abcabbc abbc
|
||||
((a{1,10}){1,10}){1,10} - a a a,a
|
||||
|
||||
# multiple repetitions
|
||||
a** &C BADRPT
|
||||
a++ C BADRPT
|
||||
a?? C BADRPT
|
||||
a*+ C BADRPT
|
||||
a*? C BADRPT
|
||||
a+* C BADRPT
|
||||
a+? C BADRPT
|
||||
a?* C BADRPT
|
||||
a?+ C BADRPT
|
||||
a{1}{1} C BADRPT
|
||||
a*{1} C BADRPT
|
||||
a+{1} C BADRPT
|
||||
a?{1} C BADRPT
|
||||
a{1}* C BADRPT
|
||||
a{1}+ C BADRPT
|
||||
a{1}? C BADRPT
|
||||
a*{b} - a{b} a{b}
|
||||
a\{1\}\{1\} bC BADRPT
|
||||
a*\{1\} bC BADRPT
|
||||
a\{1\}* bC BADRPT
|
||||
|
||||
# brackets, and numerous perversions thereof
|
||||
a[b]c & abc abc
|
||||
a[ab]c & abc abc
|
||||
a[^ab]c & adc adc
|
||||
a[]b]c & a]c a]c
|
||||
a[[b]c & a[c a[c
|
||||
a[-b]c & a-c a-c
|
||||
a[^]b]c & adc adc
|
||||
a[^-b]c & adc adc
|
||||
a[b-]c & a-c a-c
|
||||
a[b &C EBRACK
|
||||
a[] &C EBRACK
|
||||
a[1-3]c & a2c a2c
|
||||
a[3-1]c &C ERANGE
|
||||
a[1-3-5]c &C ERANGE
|
||||
a[[.-.]--]c & a-c a-c
|
||||
a[1- &C ERANGE
|
||||
a[[. &C EBRACK
|
||||
a[[.x &C EBRACK
|
||||
a[[.x. &C EBRACK
|
||||
a[[.x.] &C EBRACK
|
||||
a[[.x.]] & ax ax
|
||||
a[[.x,.]] &C ECOLLATE
|
||||
a[[.one.]]b & a1b a1b
|
||||
a[[.notdef.]]b &C ECOLLATE
|
||||
a[[.].]]b & a]b a]b
|
||||
a[[:alpha:]]c & abc abc
|
||||
a[[:notdef:]]c &C ECTYPE
|
||||
a[[: &C EBRACK
|
||||
a[[:alpha &C EBRACK
|
||||
a[[:alpha:] &C EBRACK
|
||||
a[[:alpha,:] &C ECTYPE
|
||||
a[[:]:]]b &C ECTYPE
|
||||
a[[:-:]]b &C ECTYPE
|
||||
a[[:alph:]] &C ECTYPE
|
||||
a[[:alphabet:]] &C ECTYPE
|
||||
[[:alnum:]]+ - -%@a0X- a0X
|
||||
[[:alpha:]]+ - -%@aX0- aX
|
||||
[[:blank:]]+ - aSSTb SST
|
||||
[[:cntrl:]]+ - aNTb NT
|
||||
[[:digit:]]+ - a019b 019
|
||||
[[:graph:]]+ - Sa%bS a%b
|
||||
[[:lower:]]+ - AabC ab
|
||||
[[:print:]]+ - NaSbN aSb
|
||||
[[:punct:]]+ - S%-&T %-&
|
||||
[[:space:]]+ - aSNTb SNT
|
||||
[[:upper:]]+ - aBCd BC
|
||||
[[:xdigit:]]+ - p0f3Cq 0f3C
|
||||
a[[=b=]]c & abc abc
|
||||
a[[= &C EBRACK
|
||||
a[[=b &C EBRACK
|
||||
a[[=b= &C EBRACK
|
||||
a[[=b=] &C EBRACK
|
||||
a[[=b,=]] &C ECOLLATE
|
||||
a[[=one=]]b & a1b a1b
|
||||
|
||||
# complexities
|
||||
a(((b)))c - abc abc
|
||||
a(b|(c))d - abd abd
|
||||
a(b*|c)d - abbd abbd
|
||||
# just gotta have one DFA-buster, of course
|
||||
a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
|
||||
# and an inline expansion in case somebody gets tricky
|
||||
a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
|
||||
# and in case somebody just slips in an NFA...
|
||||
a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights
|
||||
# fish for anomalies as the number of states passes 32
|
||||
12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789
|
||||
123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890
|
||||
1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901
|
||||
12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012
|
||||
123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123
|
||||
# and one really big one, beyond any plausible word width
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890
|
||||
# fish for problems as brackets go past 8
|
||||
[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm
|
||||
[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo
|
||||
[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq
|
||||
[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq
|
||||
|
||||
# subtleties of matching
|
||||
abc & xabcy abc
|
||||
a\(b\)?c\1d b acd
|
||||
aBc i Abc Abc
|
||||
a[Bc]*d i abBCcd abBCcd
|
||||
0[[:upper:]]1 &i 0a1 0a1
|
||||
0[[:lower:]]1 &i 0A1 0A1
|
||||
a[^b]c &i abc
|
||||
a[^b]c &i aBc
|
||||
a[^b]c &i adc adc
|
||||
[a]b[c] - abc abc
|
||||
[a]b[a] - aba aba
|
||||
[abc]b[abc] - abc abc
|
||||
[abc]b[abd] - abd abd
|
||||
a(b?c)+d - accd accd
|
||||
(wee|week)(knights|night) - weeknights weeknights
|
||||
(we|wee|week|frob)(knights|night|day) - weeknights weeknights
|
||||
a[bc]d - xyzaaabcaababdacd abd
|
||||
a[ab]c - aaabc abc
|
||||
abc s abc abc
|
||||
a* & b @b
|
||||
|
||||
# Let's have some fun -- try to match a C comment.
|
||||
# first the obvious, which looks okay at first glance...
|
||||
/\*.*\*/ - /*x*/ /*x*/
|
||||
# but...
|
||||
/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/
|
||||
# okay, we must not match */ inside; try to do that...
|
||||
/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/
|
||||
/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/
|
||||
# but...
|
||||
/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/
|
||||
# and a still fancier version, which does it right (I think)...
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/
|
||||
/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/
|
||||
|
||||
# subexpressions
|
||||
a(b)(c)d - abcd abcd b,c
|
||||
a(((b)))c - abc abc b,b,b
|
||||
a(b|(c))d - abd abd b,-
|
||||
a(b*|c|e)d - abbd abbd bb
|
||||
a(b*|c|e)d - acd acd c
|
||||
a(b*|c|e)d - ad ad @d
|
||||
a(b?)c - abc abc b
|
||||
a(b?)c - ac ac @c
|
||||
a(b+)c - abc abc b
|
||||
a(b+)c - abbbc abbbc bbb
|
||||
a(b*)c - ac ac @c
|
||||
(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de
|
||||
# the regression tester only asks for 9 subexpressions
|
||||
a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j
|
||||
a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k
|
||||
a([bc]?)c - abc abc b
|
||||
a([bc]?)c - ac ac @c
|
||||
a([bc]+)c - abc abc b
|
||||
a([bc]+)c - abcc abcc bc
|
||||
a([bc]+)bc - abcbc abcbc bc
|
||||
a(bb+|b)b - abb abb b
|
||||
a(bbb+|bb+|b)b - abb abb b
|
||||
a(bbb+|bb+|b)b - abbb abbb bb
|
||||
a(bbb+|bb+|b)bb - abbb abbb b
|
||||
(.*).* - abcdef abcdef abcdef
|
||||
(a*)* - bc @b @b
|
||||
|
||||
# do we get the right subexpression when it is used more than once?
|
||||
a(b|c)*d - ad ad -
|
||||
a(b|c)*d - abcd abcd c
|
||||
a(b|c)+d - abd abd b
|
||||
a(b|c)+d - abcd abcd c
|
||||
a(b|c?)+d - ad ad @d
|
||||
a(b|c?)+d - abcd abcd @d
|
||||
a(b|c){0,0}d - ad ad -
|
||||
a(b|c){0,1}d - ad ad -
|
||||
a(b|c){0,1}d - abd abd b
|
||||
a(b|c){0,2}d - ad ad -
|
||||
a(b|c){0,2}d - abcd abcd c
|
||||
a(b|c){0,}d - ad ad -
|
||||
a(b|c){0,}d - abcd abcd c
|
||||
a(b|c){1,1}d - abd abd b
|
||||
a(b|c){1,1}d - acd acd c
|
||||
a(b|c){1,2}d - abd abd b
|
||||
a(b|c){1,2}d - abcd abcd c
|
||||
a(b|c){1,}d - abd abd b
|
||||
a(b|c){1,}d - abcd abcd c
|
||||
a(b|c){2,2}d - acbd acbd b
|
||||
a(b|c){2,2}d - abcd abcd c
|
||||
a(b|c){2,4}d - abcd abcd c
|
||||
a(b|c){2,4}d - abcbd abcbd b
|
||||
a(b|c){2,4}d - abcbcd abcbcd c
|
||||
a(b|c){2,}d - abcd abcd c
|
||||
a(b|c){2,}d - abcbd abcbd b
|
||||
a(b+|((c)*))+d - abd abd @d,@d,-
|
||||
a(b+|((c)*))+d - abcd abcd @d,@d,-
|
||||
|
||||
# check out the STARTEND option
|
||||
[abc] &# a(b)c b
|
||||
[abc] &# a(d)c
|
||||
[abc] &# a(bc)d b
|
||||
[abc] &# a(dc)d c
|
||||
. &# a()c
|
||||
b.*c &# b(bc)c bc
|
||||
b.* &# b(bc)c bc
|
||||
.*c &# b(bc)c bc
|
||||
|
||||
# plain strings, with the NOSPEC flag
|
||||
abc m abc abc
|
||||
abc m xabcy abc
|
||||
abc m xyz
|
||||
a*b m aba*b a*b
|
||||
a*b m ab
|
||||
"" mC EMPTY
|
||||
|
||||
# cases involving NULs
|
||||
aZb & a a
|
||||
aZb &p a
|
||||
aZb &p# (aZb) aZb
|
||||
aZ*b &p# (ab) ab
|
||||
a.b &# (aZb) aZb
|
||||
a.* &# (aZb)c aZb
|
||||
|
||||
# word boundaries (ick)
|
||||
[[:<:]]a & a a
|
||||
[[:<:]]a & ba
|
||||
[[:<:]]a & -a a
|
||||
a[[:>:]] & a a
|
||||
a[[:>:]] & ab
|
||||
a[[:>:]] & a- a
|
||||
[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc
|
||||
[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc
|
||||
[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc
|
||||
[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc
|
||||
[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_
|
||||
[[:<:]]a_b[[:>:]] & x_a_b
|
||||
|
||||
# past problems, and suspected problems
|
||||
(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1
|
||||
abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop
|
||||
abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv
|
||||
(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11
|
||||
CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11
|
||||
Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
|
||||
a?b - ab ab
|
||||
-\{0,1\}[0-9]*$ b -5 -5
|
||||
@@ -0,0 +1,25 @@
|
||||
/* utility definitions */
|
||||
|
||||
#include "regex_extra.h"
|
||||
|
||||
#ifdef _POSIX2_RE_DUP_MAX
|
||||
#define DUPMAX _POSIX2_RE_DUP_MAX
|
||||
#else
|
||||
#define DUPMAX 255
|
||||
#endif
|
||||
#define INFINITY (DUPMAX + 1)
|
||||
#define NC (CHAR_MAX - CHAR_MIN + 1)
|
||||
typedef unsigned char uch;
|
||||
|
||||
/* switch off assertions (if not already off) if no REDEBUG */
|
||||
#ifndef REDEBUG
|
||||
#ifndef NDEBUG
|
||||
#define NDEBUG /* no assertions please */
|
||||
#endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
/* for old systems with bcopy() but no memmove() */
|
||||
#ifdef USEBCOPY
|
||||
#define memmove(d, s, c) bcopy(s, d, c)
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
RegReplace test 1
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc123";
|
||||
echo ereg_replace("123","def",$a)?>
|
||||
--EXPECT--
|
||||
abcdef
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
RegReplace test 2
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc123";
|
||||
echo ereg_replace("123","",$a)?>
|
||||
--EXPECT--
|
||||
abc
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
ereg_replace single-quote test
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="\\'test";
|
||||
echo ereg_replace("\\\\'","'",$a)
|
||||
?>
|
||||
--EXPECT--
|
||||
'test
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
simple ereg test
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="This is a nice and simple string";
|
||||
if (ereg(".*nice and simple.*",$a)) {
|
||||
echo "ok\n";
|
||||
}
|
||||
if (!ereg(".*doesn't exist.*",$a)) {
|
||||
echo "ok\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
ok
|
||||
ok
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Test Regular expression register support in ereg
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="This is a nice and simple string";
|
||||
echo ereg(".*(is).*(is).*",$a,$registers);
|
||||
echo "\n";
|
||||
echo $registers[0];
|
||||
echo "\n";
|
||||
echo $registers[1];
|
||||
echo "\n";
|
||||
echo $registers[2];
|
||||
echo "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
32
|
||||
This is a nice and simple string
|
||||
is
|
||||
is
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Test ereg_replace of start-of-line
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="This is a nice and simple string";
|
||||
echo ereg_replace("^This","That",$a);
|
||||
?>
|
||||
--EXPECT--
|
||||
That is a nice and simple string
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Test empty result buffer in reg_replace
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
$a="abcd";
|
||||
$b=ereg_replace("abcd","",$a);
|
||||
echo "strlen(\$b)=".strlen($b);
|
||||
?>
|
||||
--EXPECT--
|
||||
strlen($b)=0
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Test back-references in regular expressions
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
echo ereg_replace("([a-z]*)([-=+|]*)([0-9]+)","\\3 \\1 \\2\n","abc+-|=123");
|
||||
?>
|
||||
--EXPECT--
|
||||
123 abc +-|=
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Test split()
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
$a=split("[[:space:]]","this is a\ntest");
|
||||
echo count($a) . "\n";
|
||||
for ($i = 0; $i < count($a); $i++) {
|
||||
echo $a[$i] . "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
4
|
||||
this
|
||||
is
|
||||
a
|
||||
test
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Long back references
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc122222222223";
|
||||
echo ereg_replace("1(2*)3","\\1def\\1",$a)?>
|
||||
--EXPECT--
|
||||
abc2222222222def2222222222
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
\0 back reference
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc123";
|
||||
echo ereg_replace("123","def\\0ghi",$a)?>
|
||||
--EXPECT--
|
||||
abcdef123ghi
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
nonexisting back reference
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc123";
|
||||
echo ereg_replace("123",'def\1ghi',$a)?>
|
||||
--EXPECT--
|
||||
abcdef\1ghi
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
escapes in replace string
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="abc123";
|
||||
echo ereg_replace("123","def\\g\\\\hi\\",$a)?>
|
||||
--EXPECT--
|
||||
abcdef\g\\hi\
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
backreferences not replaced recursively
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php $a="a\\2bxc";
|
||||
echo ereg_replace("a(.*)b(.*)c","\\1",$a)?>
|
||||
--EXPECT--
|
||||
\2
|
||||
@@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
replace empty matches
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php echo ereg_replace("^","z","abc123")?>
|
||||
--EXPECT--
|
||||
zabc123
|
||||
@@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
test backslash handling in regular expressions
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php echo ereg_replace('\?',"abc","?123?")?>
|
||||
--EXPECT--
|
||||
abc123abc
|
||||
+1
-1
@@ -871,7 +871,7 @@ PHP_FUNCTION(fdf_save_string)
|
||||
RETVAL_FALSE;
|
||||
goto err;
|
||||
}
|
||||
buf = safe_emalloc(1, stat.st_size, 1);
|
||||
buf = emalloc(stat.st_size +1);
|
||||
fread(buf, stat.st_size, 1, fp);
|
||||
buf[stat.st_size] = '\0';
|
||||
fclose(fp);
|
||||
|
||||
@@ -962,19 +962,11 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
|
||||
int size;
|
||||
char *data;
|
||||
|
||||
if (strpbrk(cmd, "\r\n")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* build the output buffer */
|
||||
if (args && args[0]) {
|
||||
/* "cmd args\r\n\0" */
|
||||
if (strlen(cmd) + strlen(args) + 4 > FTP_BUFSIZE)
|
||||
return 0;
|
||||
|
||||
if (strpbrk(args, "\r\n")) {
|
||||
return 0;
|
||||
}
|
||||
size = sprintf(ftp->outbuf, "%s %s\r\n", cmd, args);
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ if test "$PHP_GD" = "yes"; then
|
||||
libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
|
||||
libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
|
||||
libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
|
||||
libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c"
|
||||
libgd/xbm.c libgd/gd_gif_out.c "
|
||||
|
||||
dnl check for fabsf and floorf which are available since C99
|
||||
AC_CHECK_FUNCS(fabsf floorf)
|
||||
|
||||
@@ -331,10 +331,6 @@ SOURCE=.\libgd\gd_png.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libgd\gd_security.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libgd\gd_ss.c
|
||||
|
||||
!IF "$(CFG)" == "gd - Win32 Release_TS GD2"
|
||||
|
||||
+5
-21
@@ -1607,28 +1607,12 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
|
||||
int lx = 0, ly = 0;
|
||||
int fx = 0, fy = 0;
|
||||
|
||||
if ((s % 360) == (e % 360)) {
|
||||
s = 0; e = 360;
|
||||
} else {
|
||||
if (s > 360) {
|
||||
s = s % 360;
|
||||
}
|
||||
while (s<0) {
|
||||
s += 360;
|
||||
}
|
||||
|
||||
if (e > 360) {
|
||||
e = e % 360;
|
||||
}
|
||||
|
||||
while (s < 0) {
|
||||
s += 360;
|
||||
}
|
||||
|
||||
while (e < s) {
|
||||
e += 360;
|
||||
}
|
||||
|
||||
if (s == e) {
|
||||
s = 0; e = 360;
|
||||
}
|
||||
while (e < s) {
|
||||
e += 360;
|
||||
}
|
||||
|
||||
for (i = s; i <= e; i++) {
|
||||
|
||||
@@ -550,9 +550,6 @@ ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)
|
||||
/*} */
|
||||
|
||||
while ((v = LWZReadByte(fd,FALSE,c)) >= 0 ) {
|
||||
if (v >= gdMaxColors) {
|
||||
v = 0;
|
||||
}
|
||||
/* This how we recognize which colors are actually used. */
|
||||
if (im->open[v]) {
|
||||
im->open[v] = 0;
|
||||
|
||||
@@ -71,11 +71,7 @@ static void gdPngErrorHandler (png_structp png_ptr, png_const_charp msg)
|
||||
|
||||
static void gdPngReadData (png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
int check;
|
||||
check = gdGetBuf(data, length, (gdIOCtx *) png_get_io_ptr(png_ptr));
|
||||
if (check != length) {
|
||||
png_error(png_ptr, "Read Error: truncated data");
|
||||
}
|
||||
gdGetBuf(data, length, (gdIOCtx *) png_get_io_ptr(png_ptr));
|
||||
}
|
||||
|
||||
static void gdPngWriteData (png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* gd_security.c
|
||||
*
|
||||
* Implements buffer overflow check routines.
|
||||
*
|
||||
* Written 2004, Phil Knirsch.
|
||||
* Based on netpbm fixes by Alan Cox.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "gd.h"
|
||||
|
||||
int overflow2(int a, int b)
|
||||
{
|
||||
if(a < 0 || b < 0) {
|
||||
php_gd_error("gd warning: one parameter to a memory allocation multiplication is negative, failing operation gracefully\n");
|
||||
return 1;
|
||||
}
|
||||
if(b == 0)
|
||||
return 0;
|
||||
if(a > INT_MAX / b) {
|
||||
php_gd_error("gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+16
-19
@@ -196,16 +196,6 @@ tweencolorkey_t;
|
||||
#include "jisx0208.h"
|
||||
#endif
|
||||
|
||||
extern int any2eucjp (char *, char *, unsigned int);
|
||||
|
||||
/* Persistent font cache until explicitly cleared */
|
||||
/* Fonts can be used across multiple images */
|
||||
|
||||
/* 2.0.16: thread safety (the font cache is shared) */
|
||||
gdMutexDeclare(gdFontCacheMutex);
|
||||
static gdCache_head_t *fontCache = NULL;
|
||||
static FT_Library library;
|
||||
|
||||
#define Tcl_UniChar int
|
||||
#define TCL_UTF_MAX 3
|
||||
static int
|
||||
@@ -750,10 +740,9 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
||||
/* find antialised color */
|
||||
|
||||
tc_key.bgcolor = *pixel;
|
||||
gdMutexLock(gdFontCacheMutex);
|
||||
tc_elem = (tweencolor_t *) gdCacheGet (tc_cache, &tc_key);
|
||||
tc_elem = (tweencolor_t *) gdCacheGet (
|
||||
tc_cache, &tc_key);
|
||||
*pixel = tc_elem->tweencolor;
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -769,15 +758,23 @@ gdroundupdown (FT_F26Dot6 v1, int updown)
|
||||
: (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
|
||||
}
|
||||
|
||||
extern int any2eucjp (char *, char *, unsigned int);
|
||||
|
||||
/* Persistent font cache until explicitly cleared */
|
||||
/* Fonts can be used across multiple images */
|
||||
|
||||
/* 2.0.16: thread safety (the font cache is shared) */
|
||||
gdMutexDeclare(gdFontCacheMutex);
|
||||
static gdCache_head_t *fontCache = NULL;
|
||||
static FT_Library library;
|
||||
|
||||
void gdFontCacheShutdown()
|
||||
{
|
||||
if (fontCache) {
|
||||
gdMutexLock(gdFontCacheMutex);
|
||||
gdCacheDelete(fontCache);
|
||||
gdMutexShutdown(gdFontCacheMutex);
|
||||
gdCacheDelete(fontCache);
|
||||
fontCache = NULL;
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
gdMutexShutdown(gdFontCacheMutex);
|
||||
FT_Done_FreeType(library);
|
||||
FT_Done_FreeType(library);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1038,7 +1035,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
} else {
|
||||
ch = c & 0xFF; /* don't extend sign */
|
||||
}
|
||||
if (*next) next++;
|
||||
next++;
|
||||
}
|
||||
break;
|
||||
case gdFTEX_Big5: {
|
||||
|
||||
@@ -21,13 +21,6 @@ extern char *gd_strtok_r(char *s, char *sep, char **state);
|
||||
#define gdPFree(ptr) pefree(ptr, 1)
|
||||
#define gdPEstrdup(ptr) pestrdup(ptr, 1)
|
||||
|
||||
/* Returns nonzero if multiplying the two quantities will
|
||||
result in integer overflow. Also returns nonzero if
|
||||
either quantity is negative. By Phil Knirsch based on
|
||||
netpbm fixes by Alan Cox. */
|
||||
|
||||
int overflow2(int a, int b);
|
||||
|
||||
#ifdef ZTS
|
||||
#define gdMutexDeclare(x) MUTEX_T x
|
||||
#define gdMutexSetup(x) x = tsrm_mutex_alloc()
|
||||
|
||||
@@ -116,15 +116,6 @@ createwbmp (int width, int height, int color)
|
||||
if ((wbmp = (Wbmp *) gdMalloc (sizeof (Wbmp))) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (overflow2(sizeof (int), width)) {
|
||||
gdFree(wbmp);
|
||||
return NULL;
|
||||
}
|
||||
if (overflow2(sizeof (int) * width, height)) {
|
||||
gdFree(wbmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((wbmp->bitmap = (int *) safe_emalloc(sizeof(int), (width * height), 0)) == NULL)
|
||||
{
|
||||
gdFree (wbmp);
|
||||
@@ -185,13 +176,6 @@ readwbmp (int (*getin) (void *in), void *in, Wbmp ** return_wbmp)
|
||||
printf ("W: %d, H: %d\n", wbmp->width, wbmp->height);
|
||||
#endif
|
||||
|
||||
if (overflow2(sizeof (int), wbmp->width) ||
|
||||
overflow2(sizeof (int) * wbmp->width, wbmp->height))
|
||||
{
|
||||
gdFree(wbmp);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if ((wbmp->bitmap = (int *) safe_emalloc(sizeof(int), (wbmp->width * wbmp->height), 0)) == NULL)
|
||||
{
|
||||
gdFree (wbmp);
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
--TEST--
|
||||
imagecreatefromwbmp with invalid wbmp
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = dirname(__FILE__) . '/_tmp.wbmp';
|
||||
$fp = fopen($filename,"wb");
|
||||
if (!$fp) {
|
||||
exit("Failed to create <$filename>");
|
||||
}
|
||||
|
||||
//write header
|
||||
$c = 0;
|
||||
fputs($fp, chr($c), 1);
|
||||
fputs($fp, $c, 1);
|
||||
|
||||
//write width = 2^32 / 4 + 1
|
||||
$c = 0x84;
|
||||
fputs($fp, chr($c), 1);
|
||||
$c = 0x80;
|
||||
fputs($fp, chr($c), 1);
|
||||
fputs($fp, chr($c), 1);
|
||||
fputs($fp, chr($c), 1);
|
||||
$c = 0x01;
|
||||
fputs($fp, chr($c), 1);
|
||||
|
||||
/*write height = 4*/
|
||||
$c = 0x04;
|
||||
fputs($fp, chr($c), 1);
|
||||
|
||||
/*write some data to cause overflow*/
|
||||
for ($i=0; $i<10000; $i++) {
|
||||
fwrite($fp, chr($c), 1);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
$im = imagecreatefromwbmp($filename);
|
||||
unlink($filename);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imagecreatefromwbmp() [/phpmanual/function.imagecreatefromwbmp.html]: gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
|
||||
in %s on line %d
|
||||
|
||||
Warning: imagecreatefromwbmp() [/phpmanual/function.imagecreatefromwbmp.html]: '%s' is not a valid WBMP file in %s on line %d
|
||||
@@ -15,8 +15,8 @@ echo gmp_strval(gmp_div_qr(10, 0))."\n";
|
||||
10 + 0 = 10
|
||||
10 + "0" = 10
|
||||
|
||||
Warning: gmp_div() [/phpmanual/function.gmp-div.html]: Zero operand not allowed in %s on line %d
|
||||
Warning: gmp_div(): Zero operand not allowed in %s on line %d
|
||||
0
|
||||
|
||||
Warning: gmp_div_qr() [/phpmanual/function.gmp-div-qr.html]: Zero operand not allowed in %s on line %d
|
||||
Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d
|
||||
0
|
||||
+2
-2
@@ -146,7 +146,7 @@ if test "$PHP_IMAP" != "no"; then
|
||||
if test "$ac_cv_utf8_mime2text" = "new"; then
|
||||
AC_DEFINE(HAVE_NEW_MIME2TEXT, 1, [Whether utf8_mime2text() has new signature])
|
||||
fi
|
||||
CFLAGS=$old_CFLAGS
|
||||
CFLAGS=$old_CPPFLAGS
|
||||
|
||||
old_CFLAGS=$CFLAGS
|
||||
CFLAGS="-I$IMAP_INC_DIR"
|
||||
@@ -161,7 +161,7 @@ if test "$PHP_IMAP" != "no"; then
|
||||
ac_cv_u8t_canonical=no
|
||||
])
|
||||
)
|
||||
CFLAGS=$old_CFLAGS
|
||||
CFLAGS=$old_CPPFLAGS
|
||||
|
||||
if test "$ac_cv_u8t_canonical" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
|
||||
AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.])
|
||||
|
||||
+4
-4
@@ -55,7 +55,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts.lib winmm.lib cclient.lib ws2_32.lib /nologo /dll /machine:I386 /out:"Release/php_imap.dll" /libpath:"..\..\Release" /libpath:"..\..\..\php_build\IMAP\C-Client"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts.lib wsock32.lib winmm.lib cclient.lib /nologo /dll /machine:I386 /out:"Release/php_imap.dll" /libpath:"..\..\Release" /libpath:"..\..\..\php_build\IMAP\C-Client"
|
||||
|
||||
!ELSEIF "$(CFG)" == "imap - Win32 Debug"
|
||||
|
||||
@@ -81,7 +81,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts_debug.lib winmm.lib cclient.lib ws2_32.lib /nologo /dll /debug /machine:I386 /out:"Debug/php_imap.dll" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"..\..\..\php_build\IMAP\C-Client"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts_debug.lib wsock32.lib winmm.lib cclient.lib /nologo /dll /debug /machine:I386 /out:"Debug/php_imap.dll" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"..\..\..\php_build\IMAP\C-Client"
|
||||
|
||||
!ELSEIF "$(CFG)" == "imap - Win32 Debug_TS"
|
||||
|
||||
@@ -107,7 +107,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib winmm.lib cclient.lib Crypt32.lib ws2_32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_imap.dll" /pdbtype:sept /libpath:"..\..\..\\" /libpath:"..\..\Debug_TS"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib wsock32.lib winmm.lib cclient.lib crypt32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_imap.dll" /pdbtype:sept /libpath:"..\..\..\\" /libpath:"..\..\Debug_TS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "imap - Win32 Release_TS"
|
||||
|
||||
@@ -133,7 +133,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib winmm.lib cclient.lib Secur32.lib CertIdl.Lib Crypt32.lib ws2_32.lib /nologo /dll /machine:I386 /nodefaultlib:"LIBCMT" /out:"..\..\Release_TS/php_imap.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\imap"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib wsock32.lib winmm.lib cclient.lib Secur32.lib CertIdl.Lib crypt32.lib /nologo /dll /machine:I386 /nodefaultlib:"LIBCMT" /out:"..\..\Release_TS/php_imap.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\imap"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
+4
-4
@@ -438,10 +438,10 @@ PHP_MINIT_FUNCTION(imap)
|
||||
#if HAVE_IMAP_KRB && defined(HAVE_IMAP_AUTH_GSS)
|
||||
auth_link(&auth_gss); /* link in the gss authenticator */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IMAP_SSL
|
||||
ssl_onceonlyinit ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* lets allow NIL */
|
||||
@@ -3258,7 +3258,7 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
|
||||
addr = NULL;
|
||||
rfc822_parse_adrlist(&addr, tempMailTo, NULL);
|
||||
while (addr) {
|
||||
if (addr->host == NULL || strcmp(addr->host, ERRHOST) == 0) {
|
||||
if (strcmp(addr->host, ERRHOST) == 0) {
|
||||
PHP_IMAP_BAD_DEST;
|
||||
} else {
|
||||
offset += sprintf(bufferTo + offset, "%s@%s,", addr->mailbox, addr->host);
|
||||
@@ -3281,7 +3281,7 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
|
||||
addr = NULL;
|
||||
rfc822_parse_adrlist(&addr, tempMailTo, NULL);
|
||||
while (addr) {
|
||||
if (addr->host == NULL || strcmp(addr->host, ERRHOST) == 0) {
|
||||
if (strcmp(addr->host, ERRHOST) == 0) {
|
||||
PHP_IMAP_BAD_DEST;
|
||||
} else {
|
||||
offset += sprintf(bufferCc + offset, "%s@%s,", addr->mailbox, addr->host);
|
||||
@@ -3301,7 +3301,7 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
|
||||
addr = NULL;
|
||||
rfc822_parse_adrlist(&addr, tempMailTo, NULL);
|
||||
while (addr) {
|
||||
if (addr->host == NULL || strcmp(addr->host, ERRHOST) == 0) {
|
||||
if (strcmp(addr->host, ERRHOST) == 0) {
|
||||
PHP_IMAP_BAD_DEST;
|
||||
} else {
|
||||
offset += sprintf(bufferBcc + offset, "%s@%s,", addr->mailbox, addr->host);
|
||||
|
||||
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "c:\ifx-client\incl\esql" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D HAVE_IFX=1 /D HAVE_IUS=1 /D "ZTS" /D ZEND_WIN32=1 /D PHP_WIN32=1 /D IFX_VERSION=921 /D COMPILE_DL_INFORMIX=1 /D ZEND_DEBUG=0 /D HAVE_IFX_IUS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D HAVE_IFX=1 /D HAVE_IUS=1 /D "ZTS" /D ZEND_WIN32=1 /D PHP_WIN32=1 /D IFX_VERSION=921 /D COMPILE_DL_INFORMIX=1 /D ZEND_DEBUG=0 /D HAVE_IFX_IUS=1 /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD BASE RSC /l 0x406 /d "NDEBUG"
|
||||
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 isqlt09a.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\Release_TS/php_ifx.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"c:\ifx-client\lib"
|
||||
# ADD LINK32 isqlt09a.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\Release_TS/php_ifx.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ifx - Win32 Debug_TS"
|
||||
|
||||
@@ -69,7 +69,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "c:\ifx-client\incl\esql" /D "_DEBUG" /D ZEND_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D HAVE_IFX=1 /D HAVE_IUS=1 /D "ZTS" /D ZEND_WIN32=1 /D PHP_WIN32=1 /D IFX_VERSION=921 /D COMPILE_DL_INFORMIX=1 /D HAVE_IFX_IUS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D HAVE_IFX=1 /D HAVE_IUS=1 /D "ZTS" /D ZEND_WIN32=1 /D PHP_WIN32=1 /D IFX_VERSION=921 /D COMPILE_DL_INFORMIX=1 /D HAVE_IFX_IUS=1 /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD BASE RSC /l 0x406 /d "_DEBUG"
|
||||
@@ -79,7 +79,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 isqlt09a.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"Debug_TS/php_ifx.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"c:\ifx-client\lib"
|
||||
# ADD LINK32 isqlt09a.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"Debug_TS/php_ifx.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INGRES_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include\ingres" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_INGRES_II" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_II=1 /D ZTS=1 /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_INGRES_II" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_II=1 /D ZTS=1 /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts.lib iilibapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_ingres.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\lib"
|
||||
# ADD LINK32 php4ts.lib oiapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_ingres.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ingres - Win32 Debug_TS"
|
||||
|
||||
@@ -68,8 +68,8 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INGRES_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_INGRES_II" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_II=1 /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INGRES_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_INGRES_II" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_II=1 /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
|
||||
@@ -3048,9 +3048,9 @@ static void _php_ibase_user(INTERNAL_FUNCTION_PARAMETERS, int operation)
|
||||
*/
|
||||
|
||||
/* Build buffer for isc_service_attach() */
|
||||
snprintf(spb_buffer, sizeof(spb_buffer), "%c%c%c%d%s%c%d%s", isc_spb_version, isc_spb_current_version, isc_spb_user_name,
|
||||
snprintf(buf, sizeof(buf), "%c%c%c%d%s%c%d%s", isc_spb_version, isc_spb_current_version, isc_spb_user_name,
|
||||
strlen(dba_user_name), dba_user_name, isc_spb_password, strlen(dba_password), dba_password);
|
||||
spb_length = strlen(spb_buffer);
|
||||
spb_length = strlen(buf);
|
||||
|
||||
/* Attach to the Service Manager */
|
||||
snprintf(service_name, sizeof(service_name), "%s:service_mgr", ib_server);
|
||||
|
||||
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase SDK\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=1 /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include\interbase" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_IBASE=1 /D "COMPILE_DL_INTERBASE" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase SDK\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_IBASE=1 /D "COMPILE_DL_INTERBASE" /FR /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40d /d "_DEBUG"
|
||||
@@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ib_util_ms.lib gds32_ms.lib php4ts_debug.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib gds32_ms.lib php4ts_debug.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_interbase.dll" /pdbtype:sept /libpath:"..\..\..\php_build\lib\interbase" /libpath:"..\..\Debug_TS"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib gds32_ms.lib php4ts_debug.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_interbase.dll" /pdbtype:sept /libpath:"..\..\..\php_build\Interbase SDK\lib_ms" /libpath:"..\..\Debug_TS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "interbase - Win32 Release_TS"
|
||||
|
||||
@@ -71,7 +71,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase SDK\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_IBASE=1 /D ZEND_DEBUG=0 /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include\interbase" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_IBASE=1 /D "COMPILE_DL_INTERBASE" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase SDK\include" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_IBASE=1 /D "COMPILE_DL_INTERBASE" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40d /d "NDEBUG"
|
||||
@@ -81,7 +81,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ib_util_ms.lib gds32_ms.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib gds32_ms.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_interbase.dll" /libpath:"..\..\..\php_build\lib\interbase" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
|
||||
# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib gds32_ms.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_interbase.dll" /libpath:"..\..\..\php_build\Interbase SDK\lib_ms" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
+13
-29
@@ -1954,9 +1954,9 @@ PHP_FUNCTION(mb_parse_str)
|
||||
string.no_encoding = from_encoding;
|
||||
old_rg = PG(register_globals);
|
||||
if (argc == 1) {
|
||||
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "1", sizeof("1")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
|
||||
PG(register_globals) = 1;
|
||||
} else {
|
||||
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "0", sizeof("0")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
|
||||
PG(register_globals) = 0;
|
||||
}
|
||||
n = 0;
|
||||
while (n < num) {
|
||||
@@ -1985,11 +1985,7 @@ PHP_FUNCTION(mb_parse_str)
|
||||
mbfl_string_clear(&resvar);
|
||||
mbfl_string_clear(&resval);
|
||||
}
|
||||
if (old_rg) {
|
||||
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "1", sizeof("1")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
|
||||
} else {
|
||||
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "0", sizeof("0")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
|
||||
}
|
||||
PG(register_globals) = old_rg;
|
||||
|
||||
if (convd != NULL) {
|
||||
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
|
||||
@@ -3506,19 +3502,19 @@ PHP_FUNCTION(mb_decode_numericentity)
|
||||
#if HAVE_SENDMAIL
|
||||
#define SKIP_LONG_HEADER_SEP_MBSTRING(str, pos) \
|
||||
if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \
|
||||
pos += 2; \
|
||||
while (str[pos + 1] == ' ' || str[pos + 1] == '\t') { \
|
||||
pos += 3; \
|
||||
while (str[pos] == ' ' || str[pos] == '\t') { \
|
||||
pos++; \
|
||||
} \
|
||||
continue; \
|
||||
} \
|
||||
|
||||
#define MAIL_ASCIIZ_CHECK_MBSTRING(str, len) \
|
||||
pp = str; \
|
||||
ee = pp + len; \
|
||||
while ((pp = memchr(pp, '\0', (ee - pp)))) { \
|
||||
*pp = ' '; \
|
||||
} \
|
||||
else if (str[pos] == '\n' && (str[pos + 1] == ' ' || str[pos + 1] == '\t')) { \
|
||||
pos += 2; \
|
||||
while (str[pos] == ' ' || str[pos] == '\t') { \
|
||||
pos++; \
|
||||
} \
|
||||
continue; \
|
||||
} \
|
||||
|
||||
PHP_FUNCTION(mb_send_mail)
|
||||
{
|
||||
@@ -3536,8 +3532,7 @@ PHP_FUNCTION(mb_send_mail)
|
||||
const mbfl_language *lang;
|
||||
int err = 0;
|
||||
char *to_r = NULL;
|
||||
int to_len, extra_cmd_len, i;
|
||||
char *pp, *ee;
|
||||
int to_len, i;
|
||||
|
||||
if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE.");
|
||||
@@ -3570,8 +3565,6 @@ PHP_FUNCTION(mb_send_mail)
|
||||
if (Z_STRVAL_PP(argv[0])) {
|
||||
to = Z_STRVAL_PP(argv[0]);
|
||||
to_len = Z_STRLEN_PP(argv[0]);
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK_MBSTRING(to, to_len);
|
||||
if (to_len > 0) {
|
||||
to_r = estrndup(to, to_len);
|
||||
for (; to_len; to_len--) {
|
||||
@@ -3608,8 +3601,6 @@ we use the
|
||||
orig_str.no_language = MBSTRG(current_language);
|
||||
orig_str.val = (unsigned char *)Z_STRVAL_PP(argv[1]);
|
||||
orig_str.len = Z_STRLEN_PP(argv[1]);
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK_MBSTRING(orig_str.val, orig_str.len);
|
||||
orig_str.no_encoding = MBSTRG(current_internal_encoding);
|
||||
if (orig_str.no_encoding == mbfl_no_encoding_invalid
|
||||
|| orig_str.no_encoding == mbfl_no_encoding_pass) {
|
||||
@@ -3632,8 +3623,6 @@ we use the
|
||||
orig_str.no_language = MBSTRG(current_language);
|
||||
orig_str.val = Z_STRVAL_PP(argv[2]);
|
||||
orig_str.len = Z_STRLEN_PP(argv[2]);
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK_MBSTRING(orig_str.val, orig_str.len);
|
||||
orig_str.no_encoding = MBSTRG(current_internal_encoding);
|
||||
|
||||
if (orig_str.no_encoding == mbfl_no_encoding_invalid
|
||||
@@ -3670,8 +3659,6 @@ we use the
|
||||
convert_to_string_ex(argv[3]);
|
||||
p = Z_STRVAL_PP(argv[3]);
|
||||
n = Z_STRLEN_PP(argv[3]);
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK_MBSTRING(p, n);
|
||||
mbfl_memory_device_strncat(&device, p, n);
|
||||
if (p[n - 1] != '\n') {
|
||||
mbfl_memory_device_strncat(&device, "\n", 1);
|
||||
@@ -3695,9 +3682,6 @@ we use the
|
||||
if (argc == 5) { /* extra options that get passed to the mailer */
|
||||
convert_to_string_ex(argv[4]);
|
||||
extra_cmd = Z_STRVAL_PP(argv[4]);
|
||||
extra_cmd_len = Z_STRLEN_PP(argv[4]);
|
||||
/* ASCIIZ check */
|
||||
MAIL_ASCIIZ_CHECK_MBSTRING(extra_cmd, extra_cmd_len);
|
||||
}
|
||||
|
||||
if (extra_cmd) {
|
||||
|
||||
+105
-96
@@ -38,10 +38,6 @@
|
||||
|
||||
static int le_mcrypt;
|
||||
|
||||
typedef struct _php_mcrypt {
|
||||
MCRYPT td;
|
||||
zend_bool init;
|
||||
} php_mcrypt;
|
||||
|
||||
function_entry mcrypt_functions[] = {
|
||||
PHP_FE(mcrypt_ecb, NULL)
|
||||
@@ -212,12 +208,10 @@ ZEND_GET_MODULE(mcrypt)
|
||||
}
|
||||
|
||||
#define MCRYPT_GET_TD_ARG \
|
||||
zval **mcryptind; \
|
||||
php_mcrypt *pm; \
|
||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &mcryptind) == FAILURE) { \
|
||||
WRONG_PARAM_COUNT \
|
||||
} \
|
||||
ZEND_FETCH_RESOURCE (pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
|
||||
#define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \
|
||||
char *dir = NULL; \
|
||||
@@ -246,12 +240,6 @@ ZEND_GET_MODULE(mcrypt)
|
||||
#define MCRYPT_ENTRY2_4(a) MCRYPT_ENTRY_NAMED(a, a)
|
||||
#endif
|
||||
|
||||
#define PHP_MCRYPT_INIT_CHECK \
|
||||
if (!pm->init) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Operation disallowed prior to mcrypt_generic_init()."); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
|
||||
#if HAVE_LIBMCRYPT24
|
||||
PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("mcrypt.algorithms_dir", NULL, PHP_INI_ALL, OnUpdateString, algorithms_dir, zend_mcrypt_globals, mcrypt_globals)
|
||||
@@ -262,13 +250,9 @@ PHP_INI_END()
|
||||
static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
#if HAVE_LIBMCRYPT24
|
||||
php_mcrypt *pm = (php_mcrypt *) rsrc->ptr;
|
||||
if (pm) {
|
||||
mcrypt_generic_deinit(pm->td);
|
||||
mcrypt_module_close(pm->td);
|
||||
efree(pm);
|
||||
pm = NULL;
|
||||
}
|
||||
MCRYPT td = (MCRYPT) rsrc->ptr;
|
||||
mcrypt_generic_deinit(td);
|
||||
mcrypt_module_close (td);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -443,7 +427,6 @@ PHP_FUNCTION(mcrypt_module_open)
|
||||
int cipher_len, cipher_dir_len;
|
||||
int mode_len, mode_dir_len;
|
||||
MCRYPT td;
|
||||
php_mcrypt *pm;
|
||||
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "ssss",
|
||||
&cipher, &cipher_len, &cipher_dir, &cipher_dir_len,
|
||||
@@ -460,10 +443,7 @@ PHP_FUNCTION(mcrypt_module_open)
|
||||
php_error (E_WARNING, "%s(): Could not open encryption module", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
pm = emalloc(sizeof(php_mcrypt));
|
||||
pm->td = td;
|
||||
pm->init = 0;
|
||||
ZEND_REGISTER_RESOURCE(return_value, pm, le_mcrypt);
|
||||
ZEND_REGISTER_RESOURCE (return_value, td, le_mcrypt);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -478,7 +458,7 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
unsigned char *key_s, *iv_s;
|
||||
char dummy[256];
|
||||
int max_key_size, key_size, iv_size;
|
||||
php_mcrypt *pm;
|
||||
MCRYPT td;
|
||||
int argc;
|
||||
int result = 0;
|
||||
|
||||
@@ -486,12 +466,12 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
MCRYPT_CHECK_PARAM_COUNT_EX (3,3)
|
||||
|
||||
zend_get_parameters_ex(3, &mcryptind, &key, &iv);
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
convert_to_string_ex(key);
|
||||
convert_to_string_ex(iv);
|
||||
ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
convert_to_string_ex (key);
|
||||
convert_to_string_ex (iv);
|
||||
|
||||
max_key_size = mcrypt_enc_get_key_size(pm->td);
|
||||
iv_size = mcrypt_enc_get_iv_size(pm->td);
|
||||
max_key_size = mcrypt_enc_get_key_size (td);
|
||||
iv_size = mcrypt_enc_get_iv_size (td);
|
||||
|
||||
if (Z_STRLEN_PP(key) == 0) {
|
||||
php_error (E_WARNING, "%s(): Key size is 0", get_active_function_name(TSRMLS_C));
|
||||
@@ -520,8 +500,8 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
}
|
||||
memcpy (iv_s, Z_STRVAL_PP(iv), iv_size);
|
||||
|
||||
mcrypt_generic_deinit(pm->td);
|
||||
result = mcrypt_generic_init(pm->td, key_s, key_size, iv_s);
|
||||
mcrypt_generic_deinit(td);
|
||||
result = mcrypt_generic_init (td, key_s, key_size, iv_s);
|
||||
|
||||
/* If this function fails, close the mcrypt module to prevent crashes
|
||||
* when further functions want to access this resource */
|
||||
@@ -540,11 +520,10 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
break;
|
||||
}
|
||||
}
|
||||
pm->init = 1;
|
||||
RETVAL_LONG(result);
|
||||
RETVAL_LONG (result);
|
||||
|
||||
efree(iv_s);
|
||||
efree(key_s);
|
||||
efree (iv_s);
|
||||
efree (key_s);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -554,7 +533,7 @@ PHP_FUNCTION(mcrypt_generic_init)
|
||||
PHP_FUNCTION(mcrypt_generic)
|
||||
{
|
||||
zval **data, **mcryptind;
|
||||
php_mcrypt *pm;
|
||||
MCRYPT td;
|
||||
int argc;
|
||||
unsigned char* data_s;
|
||||
int block_size, data_size;
|
||||
@@ -563,17 +542,12 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
MCRYPT_CHECK_PARAM_COUNT_EX (2,2)
|
||||
|
||||
zend_get_parameters_ex(2, &mcryptind, &data);
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
convert_to_string_ex(data);
|
||||
if (Z_STRLEN_PP(data) == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An empty string was passed");
|
||||
RETURN_FALSE
|
||||
}
|
||||
ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
convert_to_string_ex (data);
|
||||
|
||||
/* Check blocksize */
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
if (mcrypt_enc_is_block_mode (td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size (td);
|
||||
data_size = (((Z_STRLEN_PP(data) - 1) / block_size) + 1) * block_size;
|
||||
data_s = emalloc (data_size + 1);
|
||||
memset (data_s, 0, data_size);
|
||||
@@ -581,12 +555,12 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
}
|
||||
else { /* It's not a block algorithm */
|
||||
data_size = Z_STRLEN_PP(data);
|
||||
data_s = emalloc(data_size + 1);
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
|
||||
data_s = emalloc (data_size + 1);
|
||||
memset (data_s, 0, data_size);
|
||||
memcpy (data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
|
||||
}
|
||||
|
||||
mcrypt_generic(pm->td, data_s, data_size);
|
||||
mcrypt_generic (td, data_s, data_size);
|
||||
data_s[data_size] = '\0';
|
||||
|
||||
RETVAL_STRINGL (data_s, data_size, 1);
|
||||
@@ -600,7 +574,7 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
PHP_FUNCTION(mdecrypt_generic)
|
||||
{
|
||||
zval **data, **mcryptind;
|
||||
php_mcrypt *pm;
|
||||
MCRYPT td;
|
||||
int argc;
|
||||
char* data_s;
|
||||
int block_size, data_size;
|
||||
@@ -609,17 +583,12 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
MCRYPT_CHECK_PARAM_COUNT_EX (2,2)
|
||||
|
||||
zend_get_parameters_ex(2, &mcryptind, &data);
|
||||
ZEND_FETCH_RESOURCE(pm, php_mcrypt * , mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
PHP_MCRYPT_INIT_CHECK
|
||||
convert_to_string_ex(data);
|
||||
if (Z_STRLEN_PP(data) == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "An empty string was passed");
|
||||
RETURN_FALSE
|
||||
}
|
||||
ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt);
|
||||
convert_to_string_ex (data);
|
||||
|
||||
/* Check blocksize */
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
if (mcrypt_enc_is_block_mode (td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size (td);
|
||||
data_size = (((Z_STRLEN_PP(data) - 1) / block_size) + 1) * block_size;
|
||||
data_s = emalloc (data_size + 1);
|
||||
memset (data_s, 0, data_size);
|
||||
@@ -627,15 +596,15 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
}
|
||||
else { /* It's not a block algorithm */
|
||||
data_size = Z_STRLEN_PP(data);
|
||||
data_s = emalloc(data_size + 1);
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
|
||||
data_s = emalloc (data_size + 1);
|
||||
memset (data_s, 0, data_size);
|
||||
memcpy (data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
|
||||
}
|
||||
|
||||
mdecrypt_generic(pm->td, data_s, data_size);
|
||||
mdecrypt_generic (td, data_s, data_size);
|
||||
|
||||
RETVAL_STRINGL(data_s, data_size, 1);
|
||||
efree(data_s);
|
||||
RETVAL_STRINGL (data_s, data_size, 1);
|
||||
efree (data_s);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -644,13 +613,15 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
This function decrypts the crypttext */
|
||||
PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
int argc, i, count;
|
||||
int *key_sizes;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
argc = ZEND_NUM_ARGS();
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
key_sizes = mcrypt_enc_get_supported_key_sizes (pm->td, &count);
|
||||
key_sizes = mcrypt_enc_get_supported_key_sizes (td, &count);
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
php_error(E_ERROR, "%s(): Unable to initialize array", get_active_function_name(TSRMLS_C));
|
||||
@@ -670,8 +641,12 @@ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes)
|
||||
This function runs the self test on the algorithm specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_self_test)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
RETURN_LONG(mcrypt_enc_self_test(pm->td));
|
||||
|
||||
RETURN_LONG (mcrypt_enc_self_test (td));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -679,8 +654,12 @@ PHP_FUNCTION(mcrypt_enc_self_test)
|
||||
Free the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_module_close)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
zend_list_delete(Z_LVAL_PP(mcryptind));
|
||||
|
||||
zend_list_delete (Z_LVAL_PP(mcryptind));
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -690,13 +669,16 @@ PHP_FUNCTION(mcrypt_module_close)
|
||||
This function terminates encrypt specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_generic_end)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
#if HAVE_MCRYPT_GENERIC_DEINIT
|
||||
php_error(E_NOTICE, "%s(): This function is deprecated, please use mcrypt_generic_deinit()", get_active_function_name(TSRMLS_C));
|
||||
if (mcrypt_generic_deinit(pm->td) < 0) {
|
||||
if (mcrypt_generic_deinit (td) < 0) {
|
||||
#else
|
||||
if (mcrypt_generic_end(pm->td) < 0) {
|
||||
if (mcrypt_generic_end (td) < 0) {
|
||||
#endif
|
||||
php_error (E_WARNING, "%s(): Could not terminate encryption specifier", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE
|
||||
@@ -712,10 +694,13 @@ PHP_FUNCTION(mcrypt_generic_end)
|
||||
This function terminates encrypt specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_generic_deinit)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_generic_deinit(pm->td) < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not terminate encryption specifier");
|
||||
if (mcrypt_generic_deinit (td) < 0) {
|
||||
php_error (E_WARNING, "%s(): Could not terminate encryption specifier", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE
|
||||
}
|
||||
RETURN_TRUE
|
||||
@@ -729,13 +714,15 @@ PHP_FUNCTION(mcrypt_generic_deinit)
|
||||
Returns TRUE if the mode is for use with block algorithms */
|
||||
PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_algorithm_mode(pm->td) == 1) {
|
||||
if (mcrypt_enc_is_block_algorithm_mode (td) == 1)
|
||||
RETURN_TRUE
|
||||
} else {
|
||||
else
|
||||
RETURN_FALSE
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -744,13 +731,15 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode)
|
||||
Returns TRUE if the alrogithm is a block algorithms */
|
||||
PHP_FUNCTION(mcrypt_enc_is_block_algorithm)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_algorithm(pm->td) == 1) {
|
||||
RETURN_TRUE
|
||||
} else {
|
||||
if (mcrypt_enc_is_block_algorithm (td) == 1)
|
||||
RETURN_TRUE
|
||||
else
|
||||
RETURN_FALSE
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -759,13 +748,15 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm)
|
||||
Returns TRUE if the mode outputs blocks */
|
||||
PHP_FUNCTION(mcrypt_enc_is_block_mode)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) {
|
||||
if (mcrypt_enc_is_block_mode (td) == 1)
|
||||
RETURN_TRUE
|
||||
} else {
|
||||
else
|
||||
RETURN_FALSE
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -774,8 +765,12 @@ PHP_FUNCTION(mcrypt_enc_is_block_mode)
|
||||
Returns the block size of the cipher specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_get_block_size)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
RETURN_LONG(mcrypt_enc_get_block_size(pm->td));
|
||||
|
||||
RETURN_LONG (mcrypt_enc_get_block_size (td));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -784,8 +779,12 @@ PHP_FUNCTION(mcrypt_enc_get_block_size)
|
||||
Returns the maximum supported key size in bytes of the algorithm specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_get_key_size)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
RETURN_LONG(mcrypt_enc_get_key_size(pm->td));
|
||||
|
||||
RETURN_LONG (mcrypt_enc_get_key_size (td));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -794,8 +793,12 @@ PHP_FUNCTION(mcrypt_enc_get_key_size)
|
||||
Returns the size of the IV in bytes of the algorithm specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_get_iv_size)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
RETURN_LONG(mcrypt_enc_get_iv_size(pm->td));
|
||||
|
||||
RETURN_LONG (mcrypt_enc_get_iv_size (td));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -804,12 +807,15 @@ PHP_FUNCTION(mcrypt_enc_get_iv_size)
|
||||
Returns the name of the algorithm specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_get_algorithms_name)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
char *name;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
name = mcrypt_enc_get_algorithms_name(pm->td);
|
||||
RETVAL_STRING(name, 1);
|
||||
mcrypt_free(name);
|
||||
name = mcrypt_enc_get_algorithms_name (td);
|
||||
RETVAL_STRING (name, 1);
|
||||
mcrypt_free (name);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -818,12 +824,15 @@ PHP_FUNCTION(mcrypt_enc_get_algorithms_name)
|
||||
Returns the name of the mode specified by the descriptor td */
|
||||
PHP_FUNCTION(mcrypt_enc_get_modes_name)
|
||||
{
|
||||
zval **mcryptind;
|
||||
MCRYPT td;
|
||||
char *name;
|
||||
|
||||
MCRYPT_GET_TD_ARG
|
||||
|
||||
name = mcrypt_enc_get_modes_name(pm->td);
|
||||
RETVAL_STRING(name, 1);
|
||||
mcrypt_free(name);
|
||||
name = mcrypt_enc_get_modes_name (td);
|
||||
RETVAL_STRING (name, 1);
|
||||
mcrypt_free (name);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1436,8 +1445,8 @@ PHP_FUNCTION(mcrypt_create_iv)
|
||||
return;
|
||||
}
|
||||
|
||||
if (size <= 0 || size >= INT_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not create an IV with a size of less then 1 or greater then %d", INT_MAX);
|
||||
if (size <= 0) {
|
||||
php_error(E_WARNING, "%s(): Can not create an IV with size 0 or smaller", get_active_function_name(TSRMLS_C));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
--TEST--
|
||||
Bug #41252 (Calling mcrypt_generic without first calling mcrypt_generic_init crashes)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
echo mcrypt_generic($td,'aaaaaaaa');
|
||||
print "I'm alive!\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: mcrypt_generic() [%s]: Operation disallowed prior to mcrypt_generic_init(). in %sbug41252.php on line 3
|
||||
I'm alive!
|
||||
@@ -595,8 +595,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
WRONG_PARAM_COUNT;
|
||||
break;
|
||||
}
|
||||
/* disable local infile option for open_basedir and safe_mode */
|
||||
if (((PG(open_basedir) && PG(open_basedir)[0] != '\0') || PG(safe_mode)) && (client_flags & CLIENT_LOCAL_FILES)) {
|
||||
/* disable local infile option for open_basedir */
|
||||
if (PG(open_basedir) && strlen(PG(open_basedir)) && (client_flags & CLIENT_LOCAL_FILES)) {
|
||||
client_flags ^= CLIENT_LOCAL_FILES;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,6 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
#endif
|
||||
|
||||
mysql = (php_mysql_conn *) le->ptr;
|
||||
mysql->active_result_id = 0;
|
||||
}
|
||||
ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
|
||||
} else { /* non persistent */
|
||||
|
||||
@@ -560,7 +560,6 @@ PHP_MINIT_FUNCTION(openssl)
|
||||
le_x509 = zend_register_list_destructors_ex(php_x509_free, NULL, "OpenSSL X.509", module_number);
|
||||
le_csr = zend_register_list_destructors_ex(php_csr_free, NULL, "OpenSSL X.509 CSR", module_number);
|
||||
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_ciphers();
|
||||
OpenSSL_add_all_digests();
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ PHP_ARG_WITH(pcre-regex,for PCRE support,
|
||||
|
||||
if test "$PHP_PCRE_REGEX" != "no"; then
|
||||
if test "$PHP_PCRE_REGEX" = "yes"; then
|
||||
PHP_NEW_EXTENSION(pcre, pcrelib/pcre_chartables.c pcrelib/pcre_ucp_searchfuncs.c pcrelib/pcre_compile.c pcrelib/pcre_config.c pcrelib/pcre_exec.c pcrelib/pcre_fullinfo.c pcrelib/pcre_get.c pcrelib/pcre_globals.c pcrelib/pcre_info.c pcrelib/pcre_maketables.c pcrelib/pcre_newline.c pcrelib/pcre_ord2utf8.c pcrelib/pcre_refcount.c pcrelib/pcre_study.c pcrelib/pcre_tables.c pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c pcrelib/pcre_version.c pcrelib/pcre_xclass.c php_pcre.c, $ext_shared,,-DEXPORT= -DNEWLINE=10 -DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -DMATCH_LIMIT_RECURSION=10000000 -DMAX_NAME_SIZE=32 -DMAX_NAME_COUNT=10000 -DMAX_DUPLENGTH=30000 -DEBCDIC=0 -I@ext_srcdir@/pcrelib)
|
||||
PHP_NEW_EXTENSION(pcre, pcrelib/pcre_chartables.c pcrelib/pcre_ucp_searchfuncs.c pcrelib/pcre_compile.c pcrelib/pcre_config.c pcrelib/pcre_dfa_exec.c pcrelib/pcre_exec.c pcrelib/pcre_fullinfo.c pcrelib/pcre_get.c pcrelib/pcre_globals.c pcrelib/pcre_info.c pcrelib/pcre_maketables.c pcrelib/pcre_ord2utf8.c pcrelib/pcre_refcount.c pcrelib/pcre_study.c pcrelib/pcre_tables.c pcrelib/pcre_try_flipped.c pcrelib/pcre_valid_utf8.c pcrelib/pcre_version.c pcrelib/pcre_xclass.c php_pcre.c, $ext_shared,,-DEXPORT= -DNEWLINE=10 -DSUPPORT_UTF8 -DSUPPORT_UCP -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -DMATCH_LIMIT=10000000 -DMATCH_LIMIT_RECURSION=10000000 -DMAX_NAME_SIZE=32 -DMAX_NAME_COUNT=10000 -DMAX_DUPLENGTH=30000 -I@ext_srcdir@/pcrelib)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
|
||||
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@ PCRE LICENCE
|
||||
PCRE is a library of functions to support regular expressions whose syntax
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
|
||||
Release 6 of PCRE is distributed under the terms of the "BSD" licence, as
|
||||
specified below. The documentation for PCRE, supplied in the "doc"
|
||||
directory, is distributed under the same terms as the software itself.
|
||||
|
||||
|
||||
@@ -1,279 +1,6 @@
|
||||
ChangeLog for PCRE
|
||||
------------------
|
||||
|
||||
Version 7.0 19-Dec-06
|
||||
---------------------
|
||||
|
||||
1. Fixed a signed/unsigned compiler warning in pcre_compile.c, shown up by
|
||||
moving to gcc 4.1.1.
|
||||
|
||||
2. The -S option for pcretest uses setrlimit(); I had omitted to #include
|
||||
sys/time.h, which is documented as needed for this function. It doesn't
|
||||
seem to matter on Linux, but it showed up on some releases of OS X.
|
||||
|
||||
3. It seems that there are systems where bytes whose values are greater than
|
||||
127 match isprint() in the "C" locale. The "C" locale should be the
|
||||
default when a C program starts up. In most systems, only ASCII printing
|
||||
characters match isprint(). This difference caused the output from pcretest
|
||||
to vary, making some of the tests fail. I have changed pcretest so that:
|
||||
|
||||
(a) When it is outputting text in the compiled version of a pattern, bytes
|
||||
other than 32-126 are always shown as hex escapes.
|
||||
|
||||
(b) When it is outputting text that is a matched part of a subject string,
|
||||
it does the same, unless a different locale has been set for the match
|
||||
(using the /L modifier). In this case, it uses isprint() to decide.
|
||||
|
||||
4. Fixed a major bug that caused incorrect computation of the amount of memory
|
||||
required for a compiled pattern when options that changed within the
|
||||
pattern affected the logic of the preliminary scan that determines the
|
||||
length. The relevant options are -x, and -i in UTF-8 mode. The result was
|
||||
that the computed length was too small. The symptoms of this bug were
|
||||
either the PCRE error "internal error: code overflow" from pcre_compile(),
|
||||
or a glibc crash with a message such as "pcretest: free(): invalid next
|
||||
size (fast)". Examples of patterns that provoked this bug (shown in
|
||||
pcretest format) are:
|
||||
|
||||
/(?-x: )/x
|
||||
/(?x)(?-x: \s*#\s*)/
|
||||
/((?i)[\x{c0}])/8
|
||||
/(?i:[\x{c0}])/8
|
||||
|
||||
HOWEVER: Change 17 below makes this fix obsolete as the memory computation
|
||||
is now done differently.
|
||||
|
||||
5. Applied patches from Google to: (a) add a QuoteMeta function to the C++
|
||||
wrapper classes; (b) implement a new function in the C++ scanner that is
|
||||
more efficient than the old way of doing things because it avoids levels of
|
||||
recursion in the regex matching; (c) add a paragraph to the documentation
|
||||
for the FullMatch() function.
|
||||
|
||||
6. The escape sequence \n was being treated as whatever was defined as
|
||||
"newline". Not only was this contrary to the documentation, which states
|
||||
that \n is character 10 (hex 0A), but it also went horribly wrong when
|
||||
"newline" was defined as CRLF. This has been fixed.
|
||||
|
||||
7. In pcre_dfa_exec.c the value of an unsigned integer (the variable called c)
|
||||
was being set to -1 for the "end of line" case (supposedly a value that no
|
||||
character can have). Though this value is never used (the check for end of
|
||||
line is "zero bytes in current character"), it caused compiler complaints.
|
||||
I've changed it to 0xffffffff.
|
||||
|
||||
8. In pcre_version.c, the version string was being built by a sequence of
|
||||
C macros that, in the event of PCRE_PRERELEASE being defined as an empty
|
||||
string (as it is for production releases) called a macro with an empty
|
||||
argument. The C standard says the result of this is undefined. The gcc
|
||||
compiler treats it as an empty string (which was what was wanted) but it is
|
||||
reported that Visual C gives an error. The source has been hacked around to
|
||||
avoid this problem.
|
||||
|
||||
9. On the advice of a Windows user, included <io.h> and <fcntl.h> in Windows
|
||||
builds of pcretest, and changed the call to _setmode() to use _O_BINARY
|
||||
instead of 0x8000. Made all the #ifdefs test both _WIN32 and WIN32 (not all
|
||||
of them did).
|
||||
|
||||
10. Originally, pcretest opened its input and output without "b"; then I was
|
||||
told that "b" was needed in some environments, so it was added for release
|
||||
5.0 to both the input and output. (It makes no difference on Unix-like
|
||||
systems.) Later I was told that it is wrong for the input on Windows. I've
|
||||
now abstracted the modes into two macros, to make it easier to fiddle with
|
||||
them, and removed "b" from the input mode under Windows.
|
||||
|
||||
11. Added pkgconfig support for the C++ wrapper library, libpcrecpp.
|
||||
|
||||
12. Added -help and --help to pcretest as an official way of being reminded
|
||||
of the options.
|
||||
|
||||
13. Removed some redundant semicolons after macro calls in pcrecpparg.h.in
|
||||
and pcrecpp.cc because they annoy compilers at high warning levels.
|
||||
|
||||
14. A bit of tidying/refactoring in pcre_exec.c in the main bumpalong loop.
|
||||
|
||||
15. Fixed an occurrence of == in configure.ac that should have been = (shell
|
||||
scripts are not C programs :-) and which was not noticed because it works
|
||||
on Linux.
|
||||
|
||||
16. pcretest is supposed to handle any length of pattern and data line (as one
|
||||
line or as a continued sequence of lines) by extending its input buffer if
|
||||
necessary. This feature was broken for very long pattern lines, leading to
|
||||
a string of junk being passed to pcre_compile() if the pattern was longer
|
||||
than about 50K.
|
||||
|
||||
17. I have done a major re-factoring of the way pcre_compile() computes the
|
||||
amount of memory needed for a compiled pattern. Previously, there was code
|
||||
that made a preliminary scan of the pattern in order to do this. That was
|
||||
OK when PCRE was new, but as the facilities have expanded, it has become
|
||||
harder and harder to keep it in step with the real compile phase, and there
|
||||
have been a number of bugs (see for example, 4 above). I have now found a
|
||||
cunning way of running the real compile function in a "fake" mode that
|
||||
enables it to compute how much memory it would need, while actually only
|
||||
ever using a few hundred bytes of working memory and without too many
|
||||
tests of the mode. This should make future maintenance and development
|
||||
easier. A side effect of this work is that the limit of 200 on the nesting
|
||||
depth of parentheses has been removed (though this was never a serious
|
||||
limitation, I suspect). However, there is a downside: pcre_compile() now
|
||||
runs more slowly than before (30% or more, depending on the pattern). I
|
||||
hope this isn't a big issue. There is no effect on runtime performance.
|
||||
|
||||
18. Fixed a minor bug in pcretest: if a pattern line was not terminated by a
|
||||
newline (only possible for the last line of a file) and it was a
|
||||
pattern that set a locale (followed by /Lsomething), pcretest crashed.
|
||||
|
||||
19. Added additional timing features to pcretest. (1) The -tm option now times
|
||||
matching only, not compiling. (2) Both -t and -tm can be followed, as a
|
||||
separate command line item, by a number that specifies the number of
|
||||
repeats to use when timing. The default is 50000; this gives better
|
||||
precision, but takes uncomfortably long for very large patterns.
|
||||
|
||||
20. Extended pcre_study() to be more clever in cases where a branch of a
|
||||
subpattern has no definite first character. For example, (a*|b*)[cd] would
|
||||
previously give no result from pcre_study(). Now it recognizes that the
|
||||
first character must be a, b, c, or d.
|
||||
|
||||
21. There was an incorrect error "recursive call could loop indefinitely" if
|
||||
a subpattern (or the entire pattern) that was being tested for matching an
|
||||
empty string contained only one non-empty item after a nested subpattern.
|
||||
For example, the pattern (?>\x{100}*)\d(?R) provoked this error
|
||||
incorrectly, because the \d was being skipped in the check.
|
||||
|
||||
22. The pcretest program now has a new pattern option /B and a command line
|
||||
option -b, which is equivalent to adding /B to every pattern. This causes
|
||||
it to show the compiled bytecode, without the additional information that
|
||||
-d shows. The effect of -d is now the same as -b with -i (and similarly, /D
|
||||
is the same as /B/I).
|
||||
|
||||
23. A new optimization is now able automatically to treat some sequences such
|
||||
as a*b as a*+b. More specifically, if something simple (such as a character
|
||||
or a simple class like \d) has an unlimited quantifier, and is followed by
|
||||
something that cannot possibly match the quantified thing, the quantifier
|
||||
is automatically "possessified".
|
||||
|
||||
24. A recursive reference to a subpattern whose number was greater than 39
|
||||
went wrong under certain circumstances in UTF-8 mode. This bug could also
|
||||
have affected the operation of pcre_study().
|
||||
|
||||
25. Realized that a little bit of performance could be had by replacing
|
||||
(c & 0xc0) == 0xc0 with c >= 0xc0 when processing UTF-8 characters.
|
||||
|
||||
26. Timing data from pcretest is now shown to 4 decimal places instead of 3.
|
||||
|
||||
27. Possessive quantifiers such as a++ were previously implemented by turning
|
||||
them into atomic groups such as ($>a+). Now they have their own opcodes,
|
||||
which improves performance. This includes the automatically created ones
|
||||
from 23 above.
|
||||
|
||||
28. A pattern such as (?=(\w+))\1: which simulates an atomic group using a
|
||||
lookahead was broken if it was not anchored. PCRE was mistakenly expecting
|
||||
the first matched character to be a colon. This applied both to named and
|
||||
numbered groups.
|
||||
|
||||
29. The ucpinternal.h header file was missing its idempotency #ifdef.
|
||||
|
||||
30. I was sent a "project" file called libpcre.a.dev which I understand makes
|
||||
building PCRE on Windows easier, so I have included it in the distribution.
|
||||
|
||||
31. There is now a check in pcretest against a ridiculously large number being
|
||||
returned by pcre_exec() or pcre_dfa_exec(). If this happens in a /g or /G
|
||||
loop, the loop is abandoned.
|
||||
|
||||
32. Forward references to subpatterns in conditions such as (?(2)...) where
|
||||
subpattern 2 is defined later cause pcre_compile() to search forwards in
|
||||
the pattern for the relevant set of parentheses. This search went wrong
|
||||
when there were unescaped parentheses in a character class, parentheses
|
||||
escaped with \Q...\E, or parentheses in a #-comment in /x mode.
|
||||
|
||||
33. "Subroutine" calls and backreferences were previously restricted to
|
||||
referencing subpatterns earlier in the regex. This restriction has now
|
||||
been removed.
|
||||
|
||||
34. Added a number of extra features that are going to be in Perl 5.10. On the
|
||||
whole, these are just syntactic alternatives for features that PCRE had
|
||||
previously implemented using the Python syntax or my own invention. The
|
||||
other formats are all retained for compatibility.
|
||||
|
||||
(a) Named groups can now be defined as (?<name>...) or (?'name'...) as well
|
||||
as (?P<name>...). The new forms, as well as being in Perl 5.10, are
|
||||
also .NET compatible.
|
||||
|
||||
(b) A recursion or subroutine call to a named group can now be defined as
|
||||
(?&name) as well as (?P>name).
|
||||
|
||||
(c) A backreference to a named group can now be defined as \k<name> or
|
||||
\k'name' as well as (?P=name). The new forms, as well as being in Perl
|
||||
5.10, are also .NET compatible.
|
||||
|
||||
(d) A conditional reference to a named group can now use the syntax
|
||||
(?(<name>) or (?('name') as well as (?(name).
|
||||
|
||||
(e) A "conditional group" of the form (?(DEFINE)...) can be used to define
|
||||
groups (named and numbered) that are never evaluated inline, but can be
|
||||
called as "subroutines" from elsewhere. In effect, the DEFINE condition
|
||||
is always false. There may be only one alternative in such a group.
|
||||
|
||||
(f) A test for recursion can be given as (?(R1).. or (?(R&name)... as well
|
||||
as the simple (?(R). The condition is true only if the most recent
|
||||
recursion is that of the given number or name. It does not search out
|
||||
through the entire recursion stack.
|
||||
|
||||
(g) The escape \gN or \g{N} has been added, where N is a positive or
|
||||
negative number, specifying an absolute or relative reference.
|
||||
|
||||
35. Tidied to get rid of some further signed/unsigned compiler warnings and
|
||||
some "unreachable code" warnings.
|
||||
|
||||
36. Updated the Unicode property tables to Unicode version 5.0.0. Amongst other
|
||||
things, this adds five new scripts.
|
||||
|
||||
37. Perl ignores orphaned \E escapes completely. PCRE now does the same.
|
||||
There were also incompatibilities regarding the handling of \Q..\E inside
|
||||
character classes, for example with patterns like [\Qa\E-\Qz\E] where the
|
||||
hyphen was adjacent to \Q or \E. I hope I've cleared all this up now.
|
||||
|
||||
38. Like Perl, PCRE detects when an indefinitely repeated parenthesized group
|
||||
matches an empty string, and forcibly breaks the loop. There were bugs in
|
||||
this code in non-simple cases. For a pattern such as ^(a()*)* matched
|
||||
against aaaa the result was just "a" rather than "aaaa", for example. Two
|
||||
separate and independent bugs (that affected different cases) have been
|
||||
fixed.
|
||||
|
||||
39. Refactored the code to abolish the use of different opcodes for small
|
||||
capturing bracket numbers. This is a tidy that I avoided doing when I
|
||||
removed the limit on the number of capturing brackets for 3.5 back in 2001.
|
||||
The new approach is not only tidier, it makes it possible to reduce the
|
||||
memory needed to fix the previous bug (38).
|
||||
|
||||
40. Implemented PCRE_NEWLINE_ANY to recognize any of the Unicode newline
|
||||
sequences (http://unicode.org/unicode/reports/tr18/) as "newline" when
|
||||
processing dot, circumflex, or dollar metacharacters, or #-comments in /x
|
||||
mode.
|
||||
|
||||
41. Add \R to match any Unicode newline sequence, as suggested in the Unicode
|
||||
report.
|
||||
|
||||
42. Applied patch, originally from Ari Pollak, modified by Google, to allow
|
||||
copy construction and assignment in the C++ wrapper.
|
||||
|
||||
43. Updated pcregrep to support "--newline=any". In the process, I fixed a
|
||||
couple of bugs that could have given wrong results in the "--newline=crlf"
|
||||
case.
|
||||
|
||||
44. Added a number of casts and did some reorganization of signed/unsigned int
|
||||
variables following suggestions from Dair Grant. Also renamed the variable
|
||||
"this" as "item" because it is a C++ keyword.
|
||||
|
||||
45. Arranged for dftables to add
|
||||
|
||||
#include "pcre_internal.h"
|
||||
|
||||
to pcre_chartables.c because without it, gcc 4.x may remove the array
|
||||
definition from the final binary if PCRE is built into a static library and
|
||||
dead code stripping is activated.
|
||||
|
||||
46. For an unanchored pattern, if a match attempt fails at the start of a
|
||||
newline sequence, and the newline setting is CRLF or ANY, and the next two
|
||||
characters are CRLF, advance by two characters instead of one.
|
||||
|
||||
|
||||
Version 6.7 04-Jul-06
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ PCRE LICENCE
|
||||
PCRE is a library of functions to support regular expressions whose syntax
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Release 7 of PCRE is distributed under the terms of the "BSD" licence, as
|
||||
Release 6 of PCRE is distributed under the terms of the "BSD" licence, as
|
||||
specified below. The documentation for PCRE, supplied in the "doc"
|
||||
directory, is distributed under the same terms as the software itself.
|
||||
|
||||
|
||||
@@ -1,36 +1,6 @@
|
||||
News about PCRE releases
|
||||
------------------------
|
||||
|
||||
Release 7.0 23-Nov-06
|
||||
---------------------
|
||||
|
||||
This release has a new major number because there have been some internal
|
||||
upheavals to facilitate the addition of new optimizations and other facilities,
|
||||
and to make subsequent maintenance and extension easier. Compilation is likely
|
||||
to be a bit slower, but there should be no major effect on runtime performance.
|
||||
Previously compiled patterns are NOT upwards compatible with this release. If
|
||||
you have saved compiled patterns from a previous release, you will have to
|
||||
re-compile them. Important changes that are visible to users are:
|
||||
|
||||
1. The Unicode property tables have been updated to Unicode 5.0.0, which adds
|
||||
some more scripts.
|
||||
|
||||
2. The option PCRE_NEWLINE_ANY causes PCRE to recognize any Unicode newline
|
||||
sequence as a newline.
|
||||
|
||||
3. The \R escape matches a single Unicode newline sequence as a single unit.
|
||||
|
||||
4. New features that will appear in Perl 5.10 are now in PCRE. These include
|
||||
alternative Perl syntax for named parentheses, and Perl syntax for
|
||||
recursion.
|
||||
|
||||
5. The C++ wrapper interface has been extended by the addition of a
|
||||
QuoteMeta function and the ability to allow copy construction and
|
||||
assignment.
|
||||
|
||||
For a complete list of changes, see the ChangeLog file.
|
||||
|
||||
|
||||
Release 6.7 04-Jul-06
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ The following are generic comments about building PCRE. The interspersed
|
||||
indented commands are suggestions from Mark Tetrode as to which commands you
|
||||
might use on a Windows system to build a static library.
|
||||
|
||||
(1) Copy or rename the file config.h.in as config.h, and change the macros that
|
||||
(1) Copy or rename the file config.in as config.h, and change the macros that
|
||||
define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
|
||||
Unfortunately, because of the way Unix autoconf works, the default setting has
|
||||
to be 0. You may also want to make changes to other macros in config.h. In
|
||||
@@ -31,7 +31,7 @@ the NEWLINE macro. The default is to use '\n', thereby using whatever value
|
||||
your compiler gives to '\n'.
|
||||
|
||||
rem Mark Tetrode's commands
|
||||
copy config.h.in config.h
|
||||
copy config.in config.h
|
||||
rem Use write, because notepad cannot handle UNIX files. Change values.
|
||||
write config.h
|
||||
|
||||
@@ -56,7 +56,6 @@ character tables and writes them to that file.
|
||||
pcre_globals.c
|
||||
pcre_info.c
|
||||
pcre_maketables.c
|
||||
pcre_newline.c
|
||||
pcre_ord2utf8.c
|
||||
pcre_refcount.c
|
||||
pcre_study.c
|
||||
@@ -94,10 +93,10 @@ pcre and pcreposix libraries when linking.
|
||||
cl /F0x400000 pcretest.c pcre.lib pcreposix.lib
|
||||
|
||||
(6) Run pcretest on the testinput files in the testdata directory, and check
|
||||
that the output matches the corresponding testoutput files. Note that the
|
||||
supplied files are in Unix format, with just LF characters as line terminators.
|
||||
You may need to edit them to change this if your system uses a different
|
||||
convention.
|
||||
that the output matches the corresponding testoutput files. You must use the
|
||||
-i option when checking testinput2. Note that the supplied files are in Unix
|
||||
format, with just LF characters as line terminators. You may need to edit them
|
||||
to change this if your system uses a different convention.
|
||||
|
||||
rem Mark Tetrode's commands
|
||||
pcretest testdata\testinput1 testdata\myoutput1
|
||||
@@ -136,17 +135,6 @@ If you have a system without "configure" but where you can use a Makefile, edit
|
||||
Makefile.in to create Makefile, substituting suitable values for the variables
|
||||
at the head of the file.
|
||||
|
||||
Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
|
||||
|
||||
Some of the core BCC libraries have a version of PCRE from 1998 built in,
|
||||
which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a
|
||||
version mismatch. I'm including an easy workaround below, if you'd like to
|
||||
include it in the non-unix instructions:
|
||||
|
||||
When linking a project with BCC5.5, pcre.lib must be included before any of
|
||||
the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command
|
||||
line.
|
||||
|
||||
Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
|
||||
contributed by Paul Sokolovsky. These environments are Mingw32
|
||||
(http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
|
||||
|
||||
+15
-16
@@ -118,13 +118,13 @@ library. You can read more about them in the pcrebuild man page.
|
||||
property table); only the basic two-letter properties such as Lu are
|
||||
supported.
|
||||
|
||||
. You can build PCRE to recognize either CR or LF or the sequence CRLF or any
|
||||
of the Unicode newline sequences as indicating the end of a line. Whatever
|
||||
you specify at build time is the default; the caller of PCRE can change the
|
||||
selection at run time. The default newline indicator is a single LF character
|
||||
(the Unix standard). You can specify the default newline indicator by adding
|
||||
--newline-is-cr or --newline-is-lf or --newline-is-crlf or --newline-is-any
|
||||
to the "configure" command, respectively.
|
||||
. You can build PCRE to recognize either CR or LF or the sequence CRLF as
|
||||
indicating the end of a line. Whatever you specify at build time is the
|
||||
default; the caller of PCRE can change the selection at run time. The default
|
||||
newline indicator is a single LF character (the Unix standard). You can
|
||||
specify the default newline indicator by adding --newline-is-cr or
|
||||
--newline-is-lf or --newline-is-crlf to the "configure" command,
|
||||
respectively.
|
||||
|
||||
. When called via the POSIX interface, PCRE uses malloc() to get additional
|
||||
storage for processing capturing parentheses if there are more than 10 of
|
||||
@@ -283,7 +283,7 @@ to the values of CC and CFLAGS.
|
||||
Using HP's ANSI C++ compiler (aCC)
|
||||
----------------------------------
|
||||
|
||||
Unless C++ support is disabled by specifying the "--disable-cpp" option of the
|
||||
Unless C++ support is disabled by specifiying the "--disable-cpp" option of the
|
||||
"configure" script, you *must* include the "-AA" option in the CXXFLAGS
|
||||
environment variable in order for the C++ components to compile correctly.
|
||||
|
||||
@@ -305,8 +305,8 @@ PCRE in the same way as for Unix systems.
|
||||
|
||||
PCRE has been compiled on Windows systems and on Macintoshes, but I don't know
|
||||
the details because I don't use those systems. It should be straightforward to
|
||||
build PCRE on any system that has a Standard C compiler and library, because it
|
||||
uses only Standard C functions.
|
||||
build PCRE on any system that has a Standard C compiler, because it uses only
|
||||
Standard C functions.
|
||||
|
||||
|
||||
Testing PCRE
|
||||
@@ -325,15 +325,15 @@ NON-UNIX-USE.
|
||||
The RunTest script runs the pcretest test program (which is documented in its
|
||||
own man page) on each of the testinput files (in the testdata directory) in
|
||||
turn, and compares the output with the contents of the corresponding testoutput
|
||||
files. A file called testtry is used to hold the main output from pcretest
|
||||
file. A file called testtry is used to hold the main output from pcretest
|
||||
(testsavedregex is also used as a working file). To run pcretest on just one of
|
||||
the test files, give its number as an argument to RunTest, for example:
|
||||
|
||||
RunTest 2
|
||||
|
||||
The first test file can also be fed directly into the perltest script to check
|
||||
that Perl gives the same results. The only difference you should see is in the
|
||||
first few lines, where the Perl version is given instead of the PCRE version.
|
||||
The first file can also be fed directly into the perltest script to check that
|
||||
Perl gives the same results. The only difference you should see is in the first
|
||||
few lines, where the Perl version is given instead of the PCRE version.
|
||||
|
||||
The second set of tests check pcre_fullinfo(), pcre_info(), pcre_study(),
|
||||
pcre_copy_substring(), pcre_get_substring(), pcre_get_substring_list(), error
|
||||
@@ -442,7 +442,6 @@ The distribution should contain the following files:
|
||||
pcre_globals.c ) and some internal functions that they use
|
||||
pcre_info.c )
|
||||
pcre_maketables.c )
|
||||
pcre_newline.c )
|
||||
pcre_ord2utf8.c )
|
||||
pcre_refcount.c )
|
||||
pcre_study.c )
|
||||
@@ -526,4 +525,4 @@ The distribution should contain the following files:
|
||||
Philip Hazel
|
||||
Email local part: ph10
|
||||
Email domain: cam.ac.uk
|
||||
November 2006
|
||||
June 2006
|
||||
@@ -6,7 +6,7 @@
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Written by Philip Hazel
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -86,16 +86,7 @@ fprintf(f,
|
||||
fprintf(f,
|
||||
"This file contains the default tables for characters with codes less than\n"
|
||||
"128 (ASCII characters). These tables are used when no external tables are\n"
|
||||
"passed to PCRE.\n\n");
|
||||
fprintf(f,
|
||||
"The following #include is present because without it gcc 4.x may remove\n"
|
||||
"the array definition from the final binary if PCRE is built into a static\n"
|
||||
"library and dead code stripping is activated. This leads to link errors.\n"
|
||||
"Pulling in the header ensures that the array gets flagged as \"someone\n"
|
||||
"outside this compilation unit might reference this\" and so it will always\n"
|
||||
"be supplied to the linker. */\n\n"
|
||||
"#include \"pcre_internal.h\"\n\n");
|
||||
fprintf(f,
|
||||
"passed to PCRE. */\n\n"
|
||||
"const unsigned char _pcre_default_tables[] = {\n\n"
|
||||
"/* This table is a lower casing table. */\n\n");
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@ not operate by backtracking, as the original Henry Spencer code and current
|
||||
Perl code does, but instead checked all possibilities simultaneously by keeping
|
||||
a list of current states and checking all of them as it advanced through the
|
||||
subject string. In the terminology of Jeffrey Friedl's book, it was a "DFA
|
||||
algorithm", though it was not a traditional Finite State Machine (FSM). When
|
||||
the pattern was all used up, all remaining states were possible matches, and
|
||||
the one matching the longest subset of the subject string was chosen. This did
|
||||
not necessarily maximize the individual wild portions of the pattern, as is
|
||||
expected in Unix and Perl-style regular expressions.
|
||||
algorithm". When the pattern was all used up, all remaining states were
|
||||
possible matches, and the one matching the longest subset of the subject string
|
||||
was chosen. This did not necessarily maximize the individual wild portions of
|
||||
the pattern, as is expected in Unix and Perl-style regular expressions.
|
||||
|
||||
Historical note 2
|
||||
-----------------
|
||||
@@ -42,38 +41,14 @@ unrelated to those mentioned above), I tried at first to invent an algorithm
|
||||
that used an amount of store bounded by a multiple of the number of characters
|
||||
in the pattern, to save on compiling time. However, because of the greater
|
||||
complexity in Perl regular expressions, I couldn't do this. In any case, a
|
||||
first pass through the pattern is helpful for other reasons.
|
||||
|
||||
Computing the memory requirement: how it was
|
||||
--------------------------------------------
|
||||
|
||||
Up to and including release 6.7, PCRE worked by running a very degenerate first
|
||||
pass to calculate a maximum store size, and then a second pass to do the real
|
||||
compile - which might use a bit less than the predicted amount of memory. The
|
||||
idea was that this would turn out faster than the Henry Spencer code because
|
||||
the first pass is degenerate and the second pass can just store stuff straight
|
||||
into the vector, which it knows is big enough.
|
||||
|
||||
Computing the memory requirement: how it is
|
||||
-------------------------------------------
|
||||
|
||||
By the time I was working on a potential 6.8 release, the degenerate first pass
|
||||
had become very complicated and hard to maintain. Indeed one of the early
|
||||
things I did for 6.8 was to fix Yet Another Bug in the memory computation. Then
|
||||
I had a flash of inspiration as to how I could run the real compile function in
|
||||
a "fake" mode that enables it to compute how much memory it would need, while
|
||||
actually only ever using a few hundred bytes of working memory, and without too
|
||||
many tests of the mode that might slow it down. So I re-factored the compiling
|
||||
functions to work this way. This got rid of about 600 lines of source. It
|
||||
should make future maintenance and development easier. As this was such a major
|
||||
change, I never released 6.8, instead upping the number to 7.0 (other quite
|
||||
major changes are also present in the 7.0 release).
|
||||
|
||||
A side effect of this work is that the previous limit of 200 on the nesting
|
||||
depth of parentheses was removed. However, there is a downside: pcre_compile()
|
||||
runs more slowly than before (30% or more, depending on the pattern) because it
|
||||
is doing a full analysis of the pattern. My hope is that this is not a big
|
||||
issue.
|
||||
first pass through the pattern is needed, for a number of reasons. PCRE works
|
||||
by running a very degenerate first pass to calculate a maximum store size, and
|
||||
then a second pass to do the real compile - which may use a bit less than the
|
||||
predicted amount of store. The idea is that this is going to turn out faster
|
||||
because the first pass is degenerate and the second pass can just store stuff
|
||||
straight into the vector, which it knows is big enough. It does make the
|
||||
compiling functions bigger, of course, but they have become quite big anyway to
|
||||
handle all the Perl stuff.
|
||||
|
||||
Traditional matching function
|
||||
-----------------------------
|
||||
@@ -95,12 +70,6 @@ intreprets the same compiled pattern data as pcre_exec(); however, not all the
|
||||
facilities are available, and those that are do not always work in quite the
|
||||
same way. See the user documentation for details.
|
||||
|
||||
The algorithm that is used for pcre_dfa_exec() is not a traditional FSM,
|
||||
because it may have a number of states active at one time. More work would be
|
||||
needed at compile time to produce a traditional FSM where only one state is
|
||||
ever active at once. I believe some other regex matchers work this way.
|
||||
|
||||
|
||||
Format of compiled patterns
|
||||
---------------------------
|
||||
|
||||
@@ -110,12 +79,10 @@ item is either implicit in the opcode or contained in the data bytes that
|
||||
follow it.
|
||||
|
||||
In many cases below "two-byte" data values are specified. This is in fact just
|
||||
a default when the number is an offset within the compiled pattern. PCRE can be
|
||||
compiled to use 3-byte or 4-byte values for these offsets (impairing the
|
||||
a default. PCRE can be compiled to use 3-byte or 4-byte values (impairing the
|
||||
performance). This is necessary only when patterns whose compiled length is
|
||||
greater than 64K are going to be processed. In this description, we assume the
|
||||
"normal" compilation options. "Two-byte" data values that are counts (e.g. for
|
||||
quantifiers) are always just two bytes.
|
||||
greater than 64K are going to be processed. In this description, we assume the
|
||||
"normal" compilation options.
|
||||
|
||||
A list of all the opcodes follows:
|
||||
|
||||
@@ -142,7 +109,6 @@ These items are all just one byte long
|
||||
OP_EOD match end of data: \z
|
||||
OP_DOLL $ (end of data, or before \n in multiline)
|
||||
OP_EXTUNI match an extended Unicode character
|
||||
OP_ANYNL match any Unicode newline sequence
|
||||
|
||||
|
||||
Repeating single characters
|
||||
@@ -153,28 +119,23 @@ following opcodes:
|
||||
|
||||
OP_STAR
|
||||
OP_MINSTAR
|
||||
OP_POSSTAR
|
||||
OP_PLUS
|
||||
OP_MINPLUS
|
||||
OP_POSPLUS
|
||||
OP_QUERY
|
||||
OP_MINQUERY
|
||||
OP_POSQUERY
|
||||
|
||||
In ASCII mode, these are two-byte items; in UTF-8 mode, the length is variable.
|
||||
Those with "MIN" in their name are the minimizing versions. Those with "POS" in
|
||||
their names are possessive versions. Each is followed by the character that is
|
||||
to be repeated. Other repeats make use of
|
||||
Those with "MIN" in their name are the minimizing versions. Each is followed by
|
||||
the character that is to be repeated. Other repeats make use of
|
||||
|
||||
OP_UPTO
|
||||
OP_MINUPTO
|
||||
OP_POSUPTO
|
||||
OP_EXACT
|
||||
|
||||
which are followed by a two-byte count (most significant first) and the
|
||||
repeated character. OP_UPTO matches from 0 to the given number. A repeat with a
|
||||
non-zero minimum and a fixed maximum is coded as an OP_EXACT followed by an
|
||||
OP_UPTO (or OP_MINUPTO or OPT_POSUPTO).
|
||||
OP_UPTO (or OP_MINUPTO).
|
||||
|
||||
|
||||
Repeating character types
|
||||
@@ -186,16 +147,12 @@ byte. The opcodes are:
|
||||
|
||||
OP_TYPESTAR
|
||||
OP_TYPEMINSTAR
|
||||
OP_TYPEPOSSTAR
|
||||
OP_TYPEPLUS
|
||||
OP_TYPEMINPLUS
|
||||
OP_TYPEPOSPLUS
|
||||
OP_TYPEQUERY
|
||||
OP_TYPEMINQUERY
|
||||
OP_TYPEPOSQUERY
|
||||
OP_TYPEUPTO
|
||||
OP_TYPEMINUPTO
|
||||
OP_TYPEPOSUPTO
|
||||
OP_TYPEEXACT
|
||||
|
||||
|
||||
@@ -259,10 +216,9 @@ OP_REF is followed by two bytes containing the reference number.
|
||||
Repeating character classes and back references
|
||||
-----------------------------------------------
|
||||
|
||||
Single-character classes are handled specially (see above). This section
|
||||
applies to OP_CLASS and OP_REF. In both cases, the repeat information follows
|
||||
the base item. The matching code looks at the following opcode to see if it is
|
||||
one of
|
||||
Single-character classes are handled specially (see above). This applies to
|
||||
OP_CLASS and OP_REF. In both cases, the repeat information follows the base
|
||||
item. The matching code looks at the following opcode to see if it is one of
|
||||
|
||||
OP_CRSTAR
|
||||
OP_CRMINSTAR
|
||||
@@ -274,9 +230,7 @@ one of
|
||||
OP_CRMINRANGE
|
||||
|
||||
All but the last two are just single-byte items. The others are followed by
|
||||
four bytes of data, comprising the minimum and maximum repeat counts. There are
|
||||
no special possessive opcodes for these repeats; a possessive repeat is
|
||||
compiled into an atomic group.
|
||||
four bytes of data, comprising the minimum and maximum repeat counts.
|
||||
|
||||
|
||||
Brackets and alternation
|
||||
@@ -285,25 +239,29 @@ Brackets and alternation
|
||||
A pair of non-capturing (round) brackets is wrapped round each expression at
|
||||
compile time, so alternation always happens in the context of brackets.
|
||||
|
||||
[Note for North Americans: "bracket" to some English speakers, including
|
||||
myself, can be round, square, curly, or pointy. Hence this usage.]
|
||||
Non-capturing brackets use the opcode OP_BRA, while capturing brackets use
|
||||
OP_BRA+1, OP_BRA+2, etc. [Note for North Americans: "bracket" to some English
|
||||
speakers, including myself, can be round, square, curly, or pointy. Hence this
|
||||
usage.]
|
||||
|
||||
Non-capturing brackets use the opcode OP_BRA. Originally PCRE was limited to 99
|
||||
capturing brackets and it used a different opcode for each one. From release
|
||||
3.5, the limit was removed by putting the bracket number into the data for
|
||||
higher-numbered brackets. From release 7.0 all capturing brackets are handled
|
||||
this way, using the single opcode OP_CBRA.
|
||||
Originally PCRE was limited to 99 capturing brackets (so as not to use up all
|
||||
the opcodes). From release 3.5, there is no limit. What happens is that the
|
||||
first ones, up to EXTRACT_BASIC_MAX are handled with separate opcodes, as
|
||||
above. If there are more, the opcode is set to EXTRACT_BASIC_MAX+1, and the
|
||||
first operation in the bracket is OP_BRANUMBER, followed by a 2-byte bracket
|
||||
number. This opcode is ignored while matching, but is fished out when handling
|
||||
the bracket itself. (They could have all been done like this, but I was making
|
||||
minimal changes.)
|
||||
|
||||
A bracket opcode is followed by LINK_SIZE bytes which give the offset to the
|
||||
next alternative OP_ALT or, if there aren't any branches, to the matching
|
||||
OP_KET opcode. Each OP_ALT is followed by LINK_SIZE bytes giving the offset to
|
||||
the next one, or to the OP_KET opcode. For capturing brackets, the bracket
|
||||
number immediately follows the offset, always as a 2-byte item.
|
||||
the next one, or to the OP_KET opcode.
|
||||
|
||||
OP_KET is used for subpatterns that do not repeat indefinitely, while
|
||||
OP_KETRMIN and OP_KETRMAX are used for indefinite repetitions, minimally or
|
||||
maximally respectively. All three are followed by LINK_SIZE bytes giving (as a
|
||||
positive number) the offset back to the matching bracket opcode.
|
||||
positive number) the offset back to the matching OP_BRA opcode.
|
||||
|
||||
If a subpattern is quantified such that it is permitted to match zero times, it
|
||||
is preceded by one of OP_BRAZERO or OP_BRAMINZERO. These are single-byte
|
||||
@@ -318,14 +276,7 @@ as appropriate.
|
||||
A subpattern with a bounded maximum repetition is replicated in a nested
|
||||
fashion up to the maximum number of times, with OP_BRAZERO or OP_BRAMINZERO
|
||||
before each replication after the minimum, so that, for example, (abc){2,5} is
|
||||
compiled as (abc)(abc)((abc)((abc)(abc)?)?)?, except that each bracketed group
|
||||
has the same number.
|
||||
|
||||
When a repeated subpattern has an unbounded upper limit, it is checked to see
|
||||
whether it could match an empty string. If this is the case, the opcode in the
|
||||
final replication is changed to OP_SBRA or OP_SCBRA. This tells the matcher
|
||||
that it needs to check for matching an empty string when it hits OP_KETRMIN or
|
||||
OP_KETRMAX, and if so, to break the loop.
|
||||
compiled as (abc)(abc)((abc)((abc)(abc)?)?)?.
|
||||
|
||||
|
||||
Assertions
|
||||
@@ -341,27 +292,22 @@ each alternative of a lookbehind assertion, allowing them to have different
|
||||
fixed lengths.
|
||||
|
||||
|
||||
Once-only (atomic) subpatterns
|
||||
------------------------------
|
||||
Once-only subpatterns
|
||||
---------------------
|
||||
|
||||
These are also just like other subpatterns, but they start with the opcode
|
||||
OP_ONCE. The check for matching an empty string in an unbounded repeat is
|
||||
handled entirely at runtime, so there is just this one opcode.
|
||||
OP_ONCE.
|
||||
|
||||
|
||||
Conditional subpatterns
|
||||
-----------------------
|
||||
|
||||
These are like other subpatterns, but they start with the opcode OP_COND, or
|
||||
OP_SCOND for one that might match an empty string in an unbounded repeat. If
|
||||
These are like other subpatterns, but they start with the opcode OP_COND. If
|
||||
the condition is a back reference, this is stored at the start of the
|
||||
subpattern using the opcode OP_CREF followed by two bytes containing the
|
||||
reference number. If the condition is "in recursion" (coded as "(?(R)"), or "in
|
||||
recursion of group x" (coded as "(?(Rx)"), the group number is stored at the
|
||||
start of the subpattern using the opcode OP_RREF, and a value of zero for "the
|
||||
whole pattern". For a DEFINE condition, just the single byte OP_DEF is used (it
|
||||
has no associated data). Otherwise, a conditional subpattern always starts with
|
||||
one of the assertions.
|
||||
reference number. If the condition is "in recursion" (coded as "(?(R)"), the
|
||||
same scheme is used, with a "reference number" of 0xffff. Otherwise, a
|
||||
conditional subpattern always starts with one of the assertions.
|
||||
|
||||
|
||||
Recursion
|
||||
@@ -399,4 +345,4 @@ at compile time, and so does not cause anything to be put into the compiled
|
||||
data.
|
||||
|
||||
Philip Hazel
|
||||
November 2006
|
||||
June 2006
|
||||
+864
-1184
File diff suppressed because it is too large.
Load diff
+6
-10
@@ -5,7 +5,7 @@
|
||||
/* This is the public header file for the PCRE library, to be #included by
|
||||
applications that call the PCRE functions.
|
||||
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2005 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef _PCRE_H
|
||||
#define _PCRE_H
|
||||
|
||||
|
||||
#include "php_compat.h"
|
||||
|
||||
/* The current PCRE version information. */
|
||||
@@ -54,10 +54,10 @@ and libpcre.pc. The values are not put into configure.ac and substituted here
|
||||
cannot run ./configure. As it now stands, this file need not be edited in that
|
||||
circumstance. */
|
||||
|
||||
#define PCRE_MAJOR 7
|
||||
#define PCRE_MINOR 0
|
||||
#define PCRE_MAJOR 6
|
||||
#define PCRE_MINOR 7
|
||||
#define PCRE_PRERELEASE
|
||||
#define PCRE_DATE 18-Dec-2006
|
||||
#define PCRE_DATE 04-Jul-2006
|
||||
|
||||
/* Win32 uses DLL by default; it needs special stuff for exported functions
|
||||
when building PCRE. */
|
||||
@@ -120,7 +120,6 @@ extern "C" {
|
||||
#define PCRE_NEWLINE_CR 0x00100000
|
||||
#define PCRE_NEWLINE_LF 0x00200000
|
||||
#define PCRE_NEWLINE_CRLF 0x00300000
|
||||
#define PCRE_NEWLINE_ANY 0x00400000
|
||||
|
||||
/* Exec-time and get/set-time error codes */
|
||||
|
||||
@@ -128,8 +127,7 @@ extern "C" {
|
||||
#define PCRE_ERROR_NULL (-2)
|
||||
#define PCRE_ERROR_BADOPTION (-3)
|
||||
#define PCRE_ERROR_BADMAGIC (-4)
|
||||
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
|
||||
#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */
|
||||
#define PCRE_ERROR_UNKNOWN_NODE (-5)
|
||||
#define PCRE_ERROR_NOMEMORY (-6)
|
||||
#define PCRE_ERROR_NOSUBSTRING (-7)
|
||||
#define PCRE_ERROR_MATCHLIMIT (-8)
|
||||
@@ -146,8 +144,6 @@ extern "C" {
|
||||
#define PCRE_ERROR_DFA_WSSIZE (-19)
|
||||
#define PCRE_ERROR_DFA_RECURSE (-20)
|
||||
#define PCRE_ERROR_RECURSIONLIMIT (-21)
|
||||
#define PCRE_ERROR_NULLWSLIMIT (-22)
|
||||
#define PCRE_ERROR_BADNEWLINE (-23)
|
||||
|
||||
/* Request types for pcre_fullinfo() */
|
||||
|
||||
|
||||
+1590
-1743
File diff suppressed because it is too large.
Load diff
@@ -6,7 +6,7 @@
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Written by Philip Hazel
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+314
-580
File diff suppressed because it is too large.
Load diff
@@ -6,7 +6,7 @@
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Written by Philip Hazel
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Written by Philip Hazel
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -436,6 +436,7 @@ pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,
|
||||
int n = get_first_set(code, stringname, ovector);
|
||||
if (n <= 0) return n;
|
||||
return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Written by Philip Hazel
|
||||
Copyright (c) 1997-2006 University of Cambridge
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -51,18 +51,6 @@ differently, and global variables are not used (see pcre.in). */
|
||||
|
||||
|
||||
#ifndef VPCOMPAT
|
||||
|
||||
/**************************************************************************
|
||||
This code used to be here for use when compiling as a C++ library. However,
|
||||
according to Dair Grant it is not needed: "
|
||||
|
||||
Including 'extern "C"' in the declaration generates an "initialized and
|
||||
declared `extern'" warning from gcc 4.0.1. Since we include pcre_internal.h,
|
||||
which includes pcre.h, which declares these prototypes within an extern "C" {}
|
||||
block, we shouldn't need the prefix here.
|
||||
|
||||
So, from Release 7.0 I have cut this out.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" void *(*pcre_malloc)(size_t) = malloc;
|
||||
extern "C" void (*pcre_free)(void *) = free;
|
||||
@@ -70,13 +58,12 @@ extern "C" void *(*pcre_stack_malloc)(size_t) = malloc;
|
||||
extern "C" void (*pcre_stack_free)(void *) = free;
|
||||
extern "C" int (*pcre_callout)(pcre_callout_block *) = NULL;
|
||||
#else
|
||||
**************************************************************************/
|
||||
|
||||
void *(*pcre_malloc)(size_t) = malloc;
|
||||
void (*pcre_free)(void *) = free;
|
||||
void *(*pcre_stack_malloc)(size_t) = malloc;
|
||||
void (*pcre_stack_free)(void *) = free;
|
||||
int (*pcre_callout)(pcre_callout_block *) = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* End of pcre_globals.c */
|
||||
Loaded 100 of 198 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user