├── CREDITS ├── ereg.c ├── tests ├── 015.phpt ├── 002.phpt ├── 001.phpt ├── 011.phpt ├── 016.phpt ├── 012.phpt ├── 003.phpt ├── 013.phpt ├── 014.phpt ├── 010.phpt ├── 008.phpt ├── 007.phpt ├── 006.phpt ├── 009.phpt ├── 004.phpt ├── 005.phpt ├── ereg_variation_004.phpt ├── eregi_variation_004.phpt ├── ereg_basic_003.phpt ├── eregi_basic_003.phpt ├── sql_regcase_basic_001.phpt ├── regular_expressions.inc ├── split_variation_004.phpt ├── spliti_variation_004.phpt ├── eregi_basic_004.phpt ├── eregi_replace_basic.phpt ├── eregi_replace_basic_002.phpt ├── eregi_basic.phpt ├── ereg_basic_004.phpt ├── spliti_basic_004.phpt ├── spliti_basic_003.phpt ├── ereg_replace_basic_002.phpt ├── sql_regcase_error_001.phpt ├── split_basic_003.phpt ├── ereg_error_001.phpt ├── split_error_001.phpt ├── eregi_error_001.phpt ├── spliti_error_001.phpt ├── ereg_replace_error_001.phpt ├── eregi_replace_error_001.phpt ├── ereg_basic_002.phpt ├── eregi_basic_002.phpt ├── ereg_error_002.phpt ├── eregi_error_002.phpt ├── split_error_002.phpt ├── spliti_error_002.phpt ├── ereg_replace_error_002.phpt ├── eregi_replace_error_002.phpt ├── ereg_basic_001.phpt ├── eregi_basic_001.phpt ├── split_basic_001.phpt ├── spliti_basic_001.phpt ├── ereg_variation_002.phpt ├── eregi_variation_002.phpt ├── ereg_replace_variation_002.phpt ├── eregi_replace_variation_002.phpt ├── sql_regcase_variation_001.phpt ├── ereg_variation_001.phpt ├── eregi_variation_001.phpt ├── split_basic_002.phpt ├── spliti_basic_002.phpt ├── ereg_replace_variation_003.phpt ├── eregi_replace_variation_003.phpt ├── ereg_replace_variation_001.phpt ├── split_variation_003.phpt ├── eregi_replace_variation_001.phpt └── spliti_variation_003.phpt ├── regex ├── regerror.ih ├── debug.ih ├── main.ih ├── utils.h ├── regfree.c ├── COPYRIGHT ├── cclass.h ├── README ├── engine.ih ├── mkh ├── regex.h ├── cname.h ├── regcomp.ih ├── regerror.c ├── regexec.c ├── WHATSNEW ├── regex2.h └── debug.c ├── config.w32 ├── README.md ├── config.m4 ├── regex.patch ├── php_regex.h ├── php_ereg.h └── LICENSE /CREDITS: -------------------------------------------------------------------------------- 1 | ereg 2 | Rasmus Lerdorf, Jim Winstead, Jaakko Hyvätti 3 | -------------------------------------------------------------------------------- /ereg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php/pecl-text-ereg/master/ereg.c -------------------------------------------------------------------------------- /tests/015.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | replace empty matches 3 | --FILE-- 4 | 5 | --EXPECTF-- 6 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 7 | zabc123 8 | -------------------------------------------------------------------------------- /tests/002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | RegReplace test 2 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abc 9 | -------------------------------------------------------------------------------- /tests/001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | RegReplace test 1 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abcdef 9 | -------------------------------------------------------------------------------- /tests/011.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | \0 back reference 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abcdef123ghi 9 | -------------------------------------------------------------------------------- /tests/016.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | test backslash handling in regular expressions 3 | --FILE-- 4 | 5 | --EXPECTF-- 6 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 7 | abc123abc 8 | -------------------------------------------------------------------------------- /tests/012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | nonexisting back reference 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abcdef\1ghi 9 | -------------------------------------------------------------------------------- /tests/003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ereg_replace single-quote test 3 | --FILE-- 4 | 7 | --EXPECTF-- 8 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 9 | 'test 10 | -------------------------------------------------------------------------------- /tests/013.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | escapes in replace string 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abcdef\g\\hi\ 9 | -------------------------------------------------------------------------------- /tests/014.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | backreferences not replaced recursively 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | \2 9 | -------------------------------------------------------------------------------- /tests/010.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Long back references 3 | --FILE-- 4 | 6 | --EXPECTF-- 7 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 8 | abc2222222222def2222222222 9 | -------------------------------------------------------------------------------- /tests/008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test back-references in regular expressions 3 | --FILE-- 4 | 7 | --EXPECTF-- 8 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 9 | 123 abc +-|= 10 | -------------------------------------------------------------------------------- /tests/007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test empty result buffer in reg_replace 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 11 | strlen($b)=0 12 | -------------------------------------------------------------------------------- /tests/006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace of start-of-line 3 | --FILE-- 4 | 7 | --EXPECTF-- 8 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 9 | That is a nice and simple string 10 | -------------------------------------------------------------------------------- /regex/regerror.ih: -------------------------------------------------------------------------------- 1 | /* ========= begin header generated by ./mkh ========= */ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* === regerror.c === */ 7 | static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | /* ========= end header generated by ./mkh ========= */ 13 | -------------------------------------------------------------------------------- /tests/009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() 3 | --FILE-- 4 | 12 | --EXPECTF-- 13 | Deprecated: Function split() is deprecated in %s on line %d 14 | 4 15 | this 16 | is 17 | a 18 | test 19 | -------------------------------------------------------------------------------- /regex/debug.ih: -------------------------------------------------------------------------------- 1 | /* ========= begin header generated by ./mkh ========= */ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* === debug.c === */ 7 | void regprint(regex_t *r, FILE *d); 8 | static void s_print(register struct re_guts *g, FILE *d); 9 | static char *regchar(int ch); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | /* ========= end header generated by ./mkh ========= */ 15 | -------------------------------------------------------------------------------- /tests/004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simple ereg test 3 | --FILE-- 4 | 12 | --EXPECTF-- 13 | Deprecated: Function ereg() is deprecated in %s on line %d 14 | ok 15 | 16 | Deprecated: Function ereg() is deprecated in %s on line %d 17 | ok 18 | -------------------------------------------------------------------------------- /tests/005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Regular expression register support in ereg 3 | --FILE-- 4 | 14 | --EXPECTF-- 15 | Deprecated: Function ereg() is deprecated in %s on line %d 16 | 32 17 | This is a nice and simple string 18 | is 19 | is 20 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | // vim:ft=javascript 3 | 4 | ARG_WITH("ereg", "POSIX extended regular expressions", "no"); 5 | if (PHP_EREG != "no") { 6 | 7 | EXTENSION("ereg", "ereg.c", PHP_EREG_SHARED, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex"); 8 | ADD_SOURCES("ext/ereg/regex", "regcomp.c regexec.c regerror.c regfree.c", "ereg"); 9 | AC_DEFINE('REGEX', 1, 'Bundled regex'); 10 | AC_DEFINE('HSREGEX', 1, 'Bundled regex'); 11 | PHP_INSTALL_HEADERS("ext/ereg", "php_ereg.h php_regex.h regex/"); 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # POSIX regex functions 2 | 3 | ## Warning 4 | 5 | This extension is deprecated and unmaintained. 6 | 7 | ## Description 8 | 9 | This extension provides the ereg family of functions that were provided with 10 | PHP 3-5. These functions have been superseded by the preg family of functions 11 | provided by the PCRE extension: http://php.net/pcre 12 | 13 | Although it should be possible to build this extension with PHP 7.0, you are 14 | strongly encouraged to port your code to use PCRE, as this extension is not 15 | maintained and is available for historical reasons only. 16 | -------------------------------------------------------------------------------- /regex/main.ih: -------------------------------------------------------------------------------- 1 | /* ========= begin header generated by ./mkh ========= */ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* === main.c === */ 7 | void regress(FILE *in); 8 | void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts); 9 | int options(int type, char *s); 10 | int opt(int c, char *s); 11 | void fixstr(register char *p); 12 | char *check(char *str, regmatch_t sub, char *should); 13 | static char *eprint(int err); 14 | static int efind(char *name); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | /* ========= end header generated by ./mkh ========= */ 20 | -------------------------------------------------------------------------------- /regex/utils.h: -------------------------------------------------------------------------------- 1 | /* utility definitions */ 2 | 3 | #ifdef _POSIX2_RE_DUP_MAX 4 | #define DUPMAX _POSIX2_RE_DUP_MAX 5 | #else 6 | #define DUPMAX 255 7 | #endif 8 | #define INFINITY (DUPMAX + 1) 9 | #define NC (CHAR_MAX - CHAR_MIN + 1) 10 | typedef unsigned char uch; 11 | 12 | /* switch off assertions (if not already off) if no REDEBUG */ 13 | #ifndef REDEBUG 14 | #ifndef NDEBUG 15 | #define NDEBUG /* no assertions please */ 16 | #endif 17 | #endif 18 | #include 19 | 20 | /* for old systems with bcopy() but no memmove() */ 21 | #ifdef USEBCOPY 22 | #define memmove(d, s, c) bcopy(s, d, c) 23 | #endif 24 | -------------------------------------------------------------------------------- /tests/ereg_variation_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : usage variations - pass non-variable as arg 3, which is pass-by-ref. 3 | --FILE-- 4 | 14 | --EXPECTF-- 15 | Strict Standards: Only variables should be passed by reference in %s on line %d 16 | 17 | Deprecated: Function ereg() is deprecated in %s on line %d 18 | int(2) 19 | Done 20 | -------------------------------------------------------------------------------- /tests/eregi_variation_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : usage variations - pass non-variable as arg 3, which is pass-by-ref. 3 | --FILE-- 4 | 14 | --EXPECTF-- 15 | Strict Standards: Only variables should be passed by reference in %s on line %d 16 | 17 | Deprecated: Function eregi() is deprecated in %s on line %d 18 | int(2) 19 | Done 20 | -------------------------------------------------------------------------------- /tests/ereg_basic_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : basic functionality - long RE 3 | --FILE-- 4 | 21 | --EXPECTF-- 22 | Deprecated: Function ereg() is deprecated in %s on line %d 23 | int(1) 24 | 25 | Deprecated: Function ereg() is deprecated in %s on line %d 26 | int(2048) 27 | int(2049) 28 | Done 29 | -------------------------------------------------------------------------------- /tests/eregi_basic_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : basic functionality - long RE 3 | --FILE-- 4 | 21 | --EXPECTF-- 22 | Deprecated: Function eregi() is deprecated in %s on line %d 23 | int(1) 24 | 25 | Deprecated: Function eregi() is deprecated in %s on line %d 26 | int(2048) 27 | int(2049) 28 | Done 29 | -------------------------------------------------------------------------------- /tests/sql_regcase_basic_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test sql_regcase() function : basic functionality 3 | --FILE-- 4 | 22 | --EXPECTF-- 23 | *** Testing sql_regcase() : basic functionality *** 24 | 25 | Deprecated: Function sql_regcase() is deprecated in %s on line %d 26 | string(39) "[Ss][Tt][Rr][Ii][Nn][Gg]_[Vv][Aa][Ll]-0" 27 | Done 28 | -------------------------------------------------------------------------------- /regex/regfree.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "regex.h" 6 | #include "utils.h" 7 | #include "regex2.h" 8 | 9 | /* 10 | - regfree - free everything 11 | = API_EXPORT(void) regfree(regex_t *); 12 | */ 13 | API_EXPORT(void) 14 | regfree(preg) 15 | regex_t *preg; 16 | { 17 | register struct re_guts *g; 18 | 19 | if (preg->re_magic != MAGIC1) /* oops */ 20 | return; /* nice to complain, but hard */ 21 | 22 | g = preg->re_g; 23 | if (g == NULL || g->magic != MAGIC2) /* oops again */ 24 | return; 25 | preg->re_magic = 0; /* mark it invalid */ 26 | g->magic = 0; /* mark it invalid */ 27 | 28 | if (g->strip != NULL) 29 | free((char *)g->strip); 30 | if (g->sets != NULL) 31 | free((char *)g->sets); 32 | if (g->setbits != NULL) 33 | free((char *)g->setbits); 34 | if (g->must != NULL) 35 | free(g->must); 36 | free((char *)g); 37 | } 38 | -------------------------------------------------------------------------------- /tests/regular_expressions.inc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /regex/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. 2 | This software is not subject to any license of the American Telephone 3 | and Telegraph Company or of the Regents of the University of California. 4 | 5 | Permission is granted to anyone to use this software for any purpose on 6 | any computer system, and to alter it and redistribute it, subject 7 | to the following restrictions: 8 | 9 | 1. The author is not responsible for the consequences of use of this 10 | software, no matter how awful, even if they arise from flaws in it. 11 | 12 | 2. The origin of this software must not be misrepresented, either by 13 | explicit claim or by omission. Since few users ever read sources, 14 | credits must appear in the documentation. 15 | 16 | 3. Altered versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. Since few users 18 | ever read sources, credits must appear in the documentation. 19 | 20 | 4. This notice may not be removed or altered. 21 | -------------------------------------------------------------------------------- /regex/cclass.h: -------------------------------------------------------------------------------- 1 | /* character-class table */ 2 | static const struct cclass { 3 | const unsigned char *name; 4 | const unsigned char *chars; 5 | const unsigned char *multis; 6 | } cclasses[] = { 7 | {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""}, 8 | {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 | ""}, 10 | {"blank", " \t", ""}, 11 | {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ 12 | \25\26\27\30\31\32\33\34\35\36\37\177", ""}, 13 | {"digit", "0123456789", ""}, 14 | {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 15 | 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", 16 | ""}, 17 | {"lower", "abcdefghijklmnopqrstuvwxyz", 18 | ""}, 19 | {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 20 | 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", 21 | ""}, 22 | {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", 23 | ""}, 24 | {"space", "\t\n\v\f\r ", ""}, 25 | {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26 | ""}, 27 | {"xdigit", "0123456789ABCDEFabcdef", 28 | ""}, 29 | {NULL, 0, ""} 30 | }; 31 | -------------------------------------------------------------------------------- /tests/split_variation_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : usage variations - out-of-range values for limit 3 | --FILE-- 4 | 25 | --EXPECTF-- 26 | *** Testing split() : usage variations *** 27 | Error: 8192 - Function split() is deprecated, %s(16) 28 | array(1) { 29 | [0]=> 30 | string(9) "1 2 3 4 5" 31 | } 32 | Error: 8192 - Function split() is deprecated, %s(17) 33 | array(1) { 34 | [0]=> 35 | string(9) "1 2 3 4 5" 36 | } 37 | Done 38 | -------------------------------------------------------------------------------- /tests/spliti_variation_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : usage variations - out-of-range values for limit 3 | --FILE-- 4 | 25 | --EXPECTF-- 26 | *** Testing spliti() : usage variations *** 27 | Error: 8192 - Function spliti() is deprecated, %s(16) 28 | array(1) { 29 | [0]=> 30 | string(9) "1 2 3 4 5" 31 | } 32 | Error: 8192 - Function spliti() is deprecated, %s(17) 33 | array(1) { 34 | [0]=> 35 | string(9) "1 2 3 4 5" 36 | } 37 | Done 38 | -------------------------------------------------------------------------------- /tests/eregi_basic_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 24 | --EXPECTF-- 25 | Deprecated: Function eregi() is deprecated in %s on line %d 26 | bool(false) 27 | 28 | Deprecated: Function eregi() is deprecated in %s on line %d 29 | bool(false) 30 | 31 | Deprecated: Function eregi() is deprecated in %s on line %d 32 | bool(false) 33 | 34 | Deprecated: Function eregi() is deprecated in %s on line %d 35 | bool(false) 36 | 37 | Deprecated: Function eregi() is deprecated in %s on line %d 38 | bool(false) 39 | string(8) "original" 40 | Done 41 | -------------------------------------------------------------------------------- /tests/eregi_replace_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : basic functionality - confirm case insensitivity 3 | --FILE-- 4 | 5 | 28 | 29 | --EXPECTF-- 30 | *** Testing eregi_replace() : basic functionality *** 31 | String Before... 32 | string(50) "UPPERCASE WORDS, lowercase words, MIxED CaSe woRdS" 33 | 34 | String after... 35 | 36 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 37 | string(65) "UPPERCASE_characterS, lowercase_characters, MIxED CaSe_characterS" 38 | Done 39 | -------------------------------------------------------------------------------- /tests/eregi_replace_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 22 | --EXPECTF-- 23 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 24 | string(1) "0" 25 | 26 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 27 | string(3) "aaa" 28 | 29 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 30 | string(2) "ba" 31 | 32 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 33 | string(2) "ba" 34 | 35 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 36 | string(1) "x" 37 | Done 38 | -------------------------------------------------------------------------------- /tests/eregi_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : basic functionality - confirm case insensitivity 3 | --FILE-- 4 | 29 | --EXPECTF-- 30 | *** Testing eregi() : basic functionality *** 31 | 32 | Deprecated: Function eregi() is deprecated in %s on line %d 33 | int(5) 34 | array(1) { 35 | [0]=> 36 | string(5) "WORDS" 37 | } 38 | 39 | Deprecated: Function eregi() is deprecated in %s on line %d 40 | int(10) 41 | array(1) { 42 | [0]=> 43 | string(10) "MIxED CaSe" 44 | } 45 | Done 46 | -------------------------------------------------------------------------------- /tests/ereg_basic_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 25 | --EXPECTF-- 26 | Deprecated: Function ereg() is deprecated in %s on line %d 27 | bool(false) 28 | 29 | Deprecated: Function ereg() is deprecated in %s on line %d 30 | bool(false) 31 | 32 | Deprecated: Function ereg() is deprecated in %s on line %d 33 | bool(false) 34 | 35 | Deprecated: Function ereg() is deprecated in %s on line %d 36 | bool(false) 37 | 38 | Deprecated: Function ereg() is deprecated in %s on line %d 39 | bool(false) 40 | 41 | Deprecated: Function ereg() is deprecated in %s on line %d 42 | bool(false) 43 | string(8) "original" 44 | Done 45 | -------------------------------------------------------------------------------- /tests/spliti_basic_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : basic functionality - confirm case insensitivity 3 | --FILE-- 4 | 20 | --EXPECTF-- 21 | Deprecated: Function spliti() is deprecated in %s on line %d 22 | array(2) { 23 | [0]=> 24 | string(4) "--- " 25 | [1]=> 26 | string(4) " ---" 27 | } 28 | 29 | Deprecated: Function spliti() is deprecated in %s on line %d 30 | array(2) { 31 | [0]=> 32 | string(4) "--- " 33 | [1]=> 34 | string(4) " ---" 35 | } 36 | 37 | Deprecated: Function spliti() is deprecated in %s on line %d 38 | array(2) { 39 | [0]=> 40 | string(4) "--- " 41 | [1]=> 42 | string(4) " ---" 43 | } 44 | 45 | Deprecated: Function spliti() is deprecated in %s on line %d 46 | array(2) { 47 | [0]=> 48 | string(4) "--- " 49 | [1]=> 50 | string(4) " ---" 51 | } 52 | Done 53 | -------------------------------------------------------------------------------- /tests/spliti_basic_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 22 | --EXPECTF-- 23 | Deprecated: Function spliti() is deprecated in %s on line %d 24 | array(1) { 25 | [0]=> 26 | string(7) "-- 0 --" 27 | } 28 | 29 | Deprecated: Function spliti() is deprecated in %s on line %d 30 | array(1) { 31 | [0]=> 32 | string(11) "--- aaa ---" 33 | } 34 | 35 | Deprecated: Function spliti() is deprecated in %s on line %d 36 | array(1) { 37 | [0]=> 38 | string(10) "--- ba ---" 39 | } 40 | 41 | Deprecated: Function spliti() is deprecated in %s on line %d 42 | array(1) { 43 | [0]=> 44 | string(10) "--- ba ---" 45 | } 46 | 47 | Deprecated: Function spliti() is deprecated in %s on line %d 48 | array(1) { 49 | [0]=> 50 | string(9) "--- x ---" 51 | } 52 | Done 53 | -------------------------------------------------------------------------------- /regex/README: -------------------------------------------------------------------------------- 1 | alpha3.4 release. 2 | Thu Mar 17 23:17:18 EST 1994 3 | henry@zoo.toronto.edu 4 | 5 | See WHATSNEW for change listing. 6 | 7 | installation notes: 8 | -------- 9 | Read the comments at the beginning of Makefile before running. 10 | 11 | Utils.h contains some things that just might have to be modified on 12 | some systems, as well as a nested include (ugh) of . 13 | 14 | The "fake" directory contains quick-and-dirty fakes for some header 15 | files and routines that old systems may not have. Note also that 16 | -DUSEBCOPY will make utils.h substitute bcopy() for memmove(). 17 | 18 | After that, "make r" will build regcomp.o, regexec.o, regfree.o, 19 | and regerror.o (the actual routines), bundle them together into a test 20 | program, and run regression tests on them. No output is good output. 21 | 22 | "make lib" builds just the .o files for the actual routines (when 23 | you're happy with testing and have adjusted CFLAGS for production), 24 | and puts them together into libregex.a. You can pick up either the 25 | library or *.o ("make lib" makes sure there are no other .o files left 26 | around to confuse things). 27 | 28 | Main.c, debug.c, split.c are used for regression testing but are not part 29 | of the RE routines themselves. 30 | 31 | Regex.h goes in /usr/include. All other .h files are internal only. 32 | -------- 33 | -------------------------------------------------------------------------------- /tests/ereg_replace_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 23 | --EXPECTF-- 24 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 25 | string(1) "a" 26 | 27 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 28 | string(1) "0" 29 | 30 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 31 | string(3) "aaa" 32 | 33 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 34 | string(2) "ba" 35 | 36 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 37 | string(2) "ba" 38 | 39 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 40 | string(1) "x" 41 | Done 42 | -------------------------------------------------------------------------------- /tests/sql_regcase_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test sql_regcase() function : error conditions 3 | --FILE-- 4 | 25 | --EXPECTF-- 26 | *** Testing sql_regcase() : error conditions *** 27 | 28 | -- Testing sql_regcase() function with Zero arguments -- 29 | 30 | Deprecated: Function sql_regcase() is deprecated in %s on line %d 31 | 32 | Warning: sql_regcase() expects exactly 1 parameter, 0 given in %s on line %d 33 | NULL 34 | 35 | -- Testing sql_regcase() function with more than expected no. of arguments -- 36 | 37 | Deprecated: Function sql_regcase() is deprecated in %s on line %d 38 | 39 | Warning: sql_regcase() expects exactly 1 parameter, 2 given in %s on line %d 40 | NULL 41 | Done 42 | -------------------------------------------------------------------------------- /tests/split_basic_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : basic functionality - a few non-matches 3 | --FILE-- 4 | 23 | --EXPECTF-- 24 | Deprecated: Function split() is deprecated in %s on line %d 25 | array(1) { 26 | [0]=> 27 | string(7) "-- a --" 28 | } 29 | 30 | Deprecated: Function split() is deprecated in %s on line %d 31 | array(1) { 32 | [0]=> 33 | string(7) "-- 0 --" 34 | } 35 | 36 | Deprecated: Function split() is deprecated in %s on line %d 37 | array(1) { 38 | [0]=> 39 | string(11) "--- aaa ---" 40 | } 41 | 42 | Deprecated: Function split() is deprecated in %s on line %d 43 | array(1) { 44 | [0]=> 45 | string(10) "--- ba ---" 46 | } 47 | 48 | Deprecated: Function split() is deprecated in %s on line %d 49 | array(1) { 50 | [0]=> 51 | string(10) "--- ba ---" 52 | } 53 | 54 | Deprecated: Function split() is deprecated in %s on line %d 55 | array(1) { 56 | [0]=> 57 | string(9) "--- x ---" 58 | } 59 | Done 60 | -------------------------------------------------------------------------------- /tests/ereg_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : error conditions - wrong number of args 3 | --FILE-- 4 | 33 | --EXPECTF-- 34 | *** Testing ereg() : error conditions *** 35 | 36 | -- Testing ereg() function with more than expected no. of arguments -- 37 | 38 | Deprecated: Function ereg() is deprecated in %s on line %d 39 | 40 | Warning: ereg() expects at most 3 parameters, 4 given in %s on line %d 41 | NULL 42 | 43 | -- Testing ereg() function with less than expected no. of arguments -- 44 | 45 | Deprecated: Function ereg() is deprecated in %s on line %d 46 | 47 | Warning: ereg() expects at least 2 parameters, 1 given in %s on line %d 48 | NULL 49 | Done 50 | -------------------------------------------------------------------------------- /tests/split_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : error conditions - wrong number of args 3 | --FILE-- 4 | 29 | --EXPECTF-- 30 | *** Testing split() : error conditions - wrong number of args *** 31 | 32 | -- Testing split() function with more than expected no. of arguments -- 33 | 34 | Deprecated: Function split() is deprecated in %s on line %d 35 | 36 | Warning: split() expects at most 3 parameters, 4 given in %s on line %d 37 | NULL 38 | 39 | -- Testing split() function with less than expected no. of arguments -- 40 | 41 | Deprecated: Function split() is deprecated in %s on line %d 42 | 43 | Warning: split() expects at least 2 parameters, 1 given in %s on line %d 44 | NULL 45 | Done 46 | -------------------------------------------------------------------------------- /tests/eregi_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : error conditions - wrong number of args 3 | --FILE-- 4 | 33 | --EXPECTF-- 34 | *** Testing eregi() : error conditions *** 35 | 36 | -- Testing eregi() function with more than expected no. of arguments -- 37 | 38 | Deprecated: Function eregi() is deprecated in %s on line %d 39 | 40 | Warning: eregi() expects at most 3 parameters, 4 given in %s on line %d 41 | NULL 42 | 43 | -- Testing eregi() function with less than expected no. of arguments -- 44 | 45 | Deprecated: Function eregi() is deprecated in %s on line %d 46 | 47 | Warning: eregi() expects at least 2 parameters, 1 given in %s on line %d 48 | NULL 49 | Done 50 | -------------------------------------------------------------------------------- /tests/spliti_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : error conditions - wrong number of args 3 | --FILE-- 4 | 29 | --EXPECTF-- 30 | *** Testing spliti() : error conditions - wrong number of args *** 31 | 32 | -- Testing spliti() function with more than expected no. of arguments -- 33 | 34 | Deprecated: Function spliti() is deprecated in %s on line %d 35 | 36 | Warning: spliti() expects at most 3 parameters, 4 given in %s on line %d 37 | NULL 38 | 39 | -- Testing spliti() function with less than expected no. of arguments -- 40 | 41 | Deprecated: Function spliti() is deprecated in %s on line %d 42 | 43 | Warning: spliti() expects at least 2 parameters, 1 given in %s on line %d 44 | NULL 45 | Done 46 | -------------------------------------------------------------------------------- /regex/engine.ih: -------------------------------------------------------------------------------- 1 | /* ========= begin header generated by ./mkh ========= */ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* === engine.c === */ 7 | static int matcher(register struct re_guts *g, unsigned char *string, size_t nmatch, regmatch_t pmatch[], int eflags); 8 | static unsigned char *dissect(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); 9 | static unsigned char *backref(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst, sopno lev); 10 | static unsigned char *fast(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); 11 | static unsigned char *slow(register struct match *m, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); 12 | static states step(register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft); 13 | #define BOL (OUT+1) 14 | #define EOL (BOL+1) 15 | #define BOLEOL (BOL+2) 16 | #define NOTHING (BOL+3) 17 | #define BOW (BOL+4) 18 | #define EOW (BOL+5) 19 | #define CODEMAX (BOL+5) /* highest code used */ 20 | #define NONCHAR(c) ((c) > UCHAR_MAX) 21 | #define NNONCHAR (CODEMAX-UCHAR_MAX) 22 | #ifdef REDEBUG 23 | static void print(struct match *m, unsigned char *caption, states st, int ch, FILE *d); 24 | #endif 25 | #ifdef REDEBUG 26 | static void at(struct match *m, unsigned char *title, unsigned char *start, unsigned char *stop, sopno startst, sopno stopst); 27 | #endif 28 | #ifdef REDEBUG 29 | static unsigned char *pchar(int ch); 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | /* ========= end header generated by ./mkh ========= */ 36 | -------------------------------------------------------------------------------- /tests/ereg_replace_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : error conditions - wrong number of args 3 | --FILE-- 4 | 30 | --EXPECTF-- 31 | *** Testing ereg_replace() : error conditions *** 32 | 33 | -- Testing ereg_replace() function with more than expected no. of arguments -- 34 | 35 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 36 | 37 | Warning: ereg_replace() expects exactly 3 parameters, 4 given in %s on line %d 38 | NULL 39 | 40 | -- Testing ereg_replace() function with less than expected no. of arguments -- 41 | 42 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 43 | 44 | Warning: ereg_replace() expects exactly 3 parameters, 2 given in %s on line %d 45 | NULL 46 | Done 47 | -------------------------------------------------------------------------------- /tests/eregi_replace_error_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : error conditions - wrong number of args 3 | --FILE-- 4 | 30 | --EXPECTF-- 31 | *** Testing eregi_replace() : error conditions *** 32 | 33 | -- Testing eregi_replace() function with more than expected no. of arguments -- 34 | 35 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 36 | 37 | Warning: eregi_replace() expects exactly 3 parameters, 4 given in %s on line %d 38 | NULL 39 | 40 | -- Testing eregi_replace() function with less than expected no. of arguments -- 41 | 42 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 43 | 44 | Warning: eregi_replace() expects exactly 3 parameters, 2 given in %s on line %d 45 | NULL 46 | Done 47 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl $Id$ 2 | dnl config.m4 for extension ereg 3 | 4 | dnl 5 | dnl Check for regex library type 6 | dnl 7 | PHP_ARG_WITH(regex,, 8 | [ --with-regex=TYPE Regex library type: system, php. [TYPE=php] 9 | WARNING: Do NOT use unless you know what you are doing!], php) 10 | 11 | case $PHP_REGEX in 12 | system) 13 | if test "$PHP_SAPI" = "apache" || test "$PHP_SAPI" = "apache2filter" || test "$PHP_SAPI" = "apache2handler"; then 14 | REGEX_TYPE=php 15 | else 16 | REGEX_TYPE=system 17 | fi 18 | ;; 19 | yes | php) 20 | REGEX_TYPE=php 21 | ;; 22 | *) 23 | REGEX_TYPE=php 24 | AC_MSG_WARN([Invalid regex library type selected. Using default value: php]) 25 | ;; 26 | esac 27 | 28 | AC_MSG_CHECKING([which regex library to use]) 29 | AC_MSG_RESULT([$REGEX_TYPE]) 30 | 31 | if test "$REGEX_TYPE" = "php"; then 32 | ereg_regex_sources="regex/regcomp.c regex/regexec.c regex/regerror.c regex/regfree.c" 33 | ereg_regex_headers="regex/" 34 | PHP_EREG_CFLAGS="-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp" 35 | fi 36 | PHP_EREG_CFLAGS="$PHP_EREG_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" 37 | 38 | PHP_NEW_EXTENSION(ereg, ereg.c $ereg_regex_sources, $ext_shared,, $PHP_EREG_CFLAGS) 39 | PHP_INSTALL_HEADERS([ext/ereg], [php_ereg.h php_regex.h $ereg_regex_headers]) 40 | 41 | if test "$REGEX_TYPE" = "php"; then 42 | AC_DEFINE(HAVE_REGEX_T_RE_MAGIC, 1, [ ]) 43 | AC_DEFINE(HSREGEX,1,[ ]) 44 | AC_DEFINE(REGEX,1,[ ]) 45 | PHP_ADD_BUILD_DIR([$ext_builddir/regex], 1) 46 | PHP_ADD_INCLUDE([$ext_srcdir/regex]) 47 | elif test "$REGEX_TYPE" = "system"; then 48 | AC_DEFINE(REGEX,0,[ ]) 49 | dnl Check if field re_magic exists in struct regex_t 50 | AC_CACHE_CHECK([whether field re_magic exists in struct regex_t], ac_cv_regex_t_re_magic, [ 51 | AC_TRY_COMPILE([#include 52 | #include ], [regex_t rt; rt.re_magic;], 53 | [ac_cv_regex_t_re_magic=yes], [ac_cv_regex_t_re_magic=no])]) 54 | if test "$ac_cv_regex_t_re_magic" = "yes"; then 55 | AC_DEFINE([HAVE_REGEX_T_RE_MAGIC], [ ], 1) 56 | fi 57 | fi 58 | -------------------------------------------------------------------------------- /regex/mkh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkh - pull headers out of C source 3 | PATH=/bin:/usr/bin ; export PATH 4 | 5 | # egrep pattern to pick out marked lines 6 | egrep='^ =([ ]|$)' 7 | 8 | # Sed program to process marked lines into lines for the header file. 9 | # The markers have already been removed. Two things are done here: removal 10 | # of backslashed newlines, and some fudging of comments. The first is done 11 | # because -o needs to have prototypes on one line to strip them down. 12 | # Getting comments into the output is tricky; we turn C++-style // comments 13 | # into /* */ comments, after altering any existing */'s to avoid trouble. 14 | peel=' /\\$/N 15 | /\\\n[ ]*/s///g 16 | /\/\//s;\*/;* /;g 17 | /\/\//s;//\(.*\);/*\1 */;' 18 | 19 | for a 20 | do 21 | case "$a" in 22 | -o) # old (pre-function-prototype) compiler 23 | # add code to comment out argument lists 24 | peel="$peel 25 | "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);' 26 | shift 27 | ;; 28 | -b) # funny Berkeley __P macro 29 | peel="$peel 30 | "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));' 31 | shift 32 | ;; 33 | -s) # compiler doesn't like `static foo();' 34 | # add code to get rid of the `static' 35 | peel="$peel 36 | "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;' 37 | shift 38 | ;; 39 | -p) # private declarations 40 | egrep='^ ==([ ]|$)' 41 | shift 42 | ;; 43 | -i) # wrap in #ifndef, argument is name 44 | ifndef="$2" 45 | shift ; shift 46 | ;; 47 | *) break 48 | ;; 49 | esac 50 | done 51 | 52 | if test " $ifndef" != " " 53 | then 54 | echo "#ifndef $ifndef" 55 | echo "#define $ifndef /* never again */" 56 | fi 57 | echo "/* ========= begin header generated by $0 ========= */" 58 | echo '#ifdef __cplusplus' 59 | echo 'extern "C" {' 60 | echo '#endif' 61 | for f 62 | do 63 | echo 64 | echo "/* === $f === */" 65 | egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel" 66 | echo 67 | done 68 | echo '#ifdef __cplusplus' 69 | echo '}' 70 | echo '#endif' 71 | echo "/* ========= end header generated by $0 ========= */" 72 | if test " $ifndef" != " " 73 | then 74 | echo "#endif" 75 | fi 76 | exit 0 77 | -------------------------------------------------------------------------------- /regex.patch: -------------------------------------------------------------------------------- 1 | diff -u regex.orig/regerror.c regex/regerror.c 2 | --- regex.orig/regerror.c 2011-08-09 19:49:30.000000000 +0800 3 | +++ regex/regerror.c 2011-08-12 10:45:57.000000000 +0800 4 | @@ -8,6 +8,7 @@ 5 | #include "regex.h" 6 | #include "utils.h" 7 | #include "regerror.ih" 8 | +#include "php.h" 9 | 10 | /* 11 | = #define REG_OKAY 0 12 | @@ -74,17 +75,19 @@ 13 | char convbuf[50]; 14 | 15 | if (errcode == REG_ATOI) 16 | - s = regatoi(preg, convbuf); 17 | + s = regatoi(preg, convbuf, sizeof(convbuf)); 18 | else { 19 | for (r = rerrs; r->code >= 0; r++) 20 | if (r->code == target) 21 | break; 22 | 23 | if (errcode®_ITOA) { 24 | - if (r->code >= 0) 25 | - (void) strcpy(convbuf, r->name); 26 | - else 27 | - sprintf(convbuf, "REG_0x%x", target); 28 | + if (r->code >= 0) { 29 | + (void) strncpy(convbuf, r->name, sizeof(convbuf) - 1); 30 | + convbuf[sizeof(convbuf) - 1] = '\0'; 31 | + } else { 32 | + snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target); 33 | + } 34 | assert(strlen(convbuf) < sizeof(convbuf)); 35 | s = convbuf; 36 | } else 37 | @@ -106,12 +109,13 @@ 38 | 39 | /* 40 | - regatoi - internal routine to implement REG_ATOI 41 | - == static char *regatoi(const regex_t *preg, char *localbuf); 42 | + == static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); 43 | */ 44 | static char * 45 | -regatoi(preg, localbuf) 46 | +regatoi(preg, localbuf, bufsize) 47 | const regex_t *preg; 48 | char *localbuf; 49 | +int bufsize; 50 | { 51 | register const struct rerr *r; 52 | 53 | @@ -121,6 +125,6 @@ 54 | if (r->code < 0) 55 | return("0"); 56 | 57 | - sprintf(localbuf, "%d", r->code); 58 | + snprintf(localbuf, bufsize, "%d", r->code); 59 | return(localbuf); 60 | } 61 | diff -u regex.orig/regerror.ih regex/regerror.ih 62 | --- regex.orig/regerror.ih 2011-08-09 19:49:00.000000000 +0800 63 | +++ regex/regerror.ih 2011-08-09 19:41:07.000000000 +0800 64 | @@ -4,7 +4,7 @@ 65 | #endif 66 | 67 | /* === regerror.c === */ 68 | -static char *regatoi(const regex_t *preg, char *localbuf); 69 | +static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); 70 | 71 | #ifdef __cplusplus 72 | } 73 | -------------------------------------------------------------------------------- /php_regex.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 7 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2015 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef PHP_REGEX_H 22 | #define PHP_REGEX_H 23 | 24 | /* 25 | * REGEX means: 26 | * 0.. system regex 27 | * 1.. bundled regex 28 | */ 29 | 30 | #if (REGEX == 1) 31 | /* Define aliases */ 32 | #define regexec php_regexec 33 | #define regerror php_regerror 34 | #define regfree php_regfree 35 | #define regcomp php_regcomp 36 | 37 | #include "ext/ereg/regex/regex.h" 38 | 39 | #undef _PCREPOSIX_H 40 | #define _PCREPOSIX_H 1 41 | 42 | #ifndef _REGEX_H 43 | #define _REGEX_H 1 /* this should stop Apache from loading the system version of regex.h */ 44 | #endif 45 | #ifndef _REGEX_H_ 46 | #define _REGEX_H_ 1 47 | #endif 48 | #ifndef _RX_H 49 | #define _RX_H 1 /* Try defining these for Linux to */ 50 | #endif 51 | #ifndef __REGEXP_LIBRARY_H__ 52 | #define __REGEXP_LIBRARY_H__ 1 /* avoid Apache including regex.h */ 53 | #endif 54 | #ifndef _H_REGEX 55 | #define _H_REGEX 1 /* This one is for AIX */ 56 | #endif 57 | 58 | #elif REGEX == 0 59 | #include 60 | #ifndef _REGEX_H_ 61 | #define _REGEX_H_ 1 62 | #endif 63 | #endif 64 | 65 | #endif /* PHP_REGEX_H */ 66 | -------------------------------------------------------------------------------- /php_ereg.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 7 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2015 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Rasmus Lerdorf | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | 19 | 20 | /* $Id$ */ 21 | 22 | #ifndef EREG_H 23 | #define EREG_H 24 | 25 | #include "php_regex.h" 26 | 27 | extern zend_module_entry ereg_module_entry; 28 | #define phpext_ereg_ptr &ereg_module_entry 29 | 30 | #ifdef PHP_WIN32 31 | # define PHP_EREG_API __declspec(dllexport) 32 | #elif defined(__GNUC__) && __GNUC__ >= 4 33 | # define PHP_EREG_API __attribute__ ((visibility("default"))) 34 | #else 35 | # define PHP_EREG_API 36 | #endif 37 | 38 | PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended); 39 | 40 | PHP_FUNCTION(ereg); 41 | PHP_FUNCTION(eregi); 42 | PHP_FUNCTION(eregi_replace); 43 | PHP_FUNCTION(ereg_replace); 44 | PHP_FUNCTION(split); 45 | PHP_FUNCTION(spliti); 46 | PHP_EREG_API PHP_FUNCTION(sql_regcase); 47 | 48 | ZEND_BEGIN_MODULE_GLOBALS(ereg) 49 | HashTable ht_rc; 50 | unsigned int lru_counter; 51 | ZEND_END_MODULE_GLOBALS(ereg) 52 | 53 | /* Module functions */ 54 | PHP_MINFO_FUNCTION(ereg); 55 | 56 | #ifdef ZTS 57 | #define EREG(v) ZEND_TSRMG(ereg_globals_id, zend_ereg_globals *, v) 58 | #else 59 | #define EREG(v) (ereg_globals.v) 60 | #endif 61 | 62 | ZEND_EXTERN_MODULE_GLOBALS(ereg) 63 | 64 | #endif /* REG_H */ 65 | -------------------------------------------------------------------------------- /regex/regex.h: -------------------------------------------------------------------------------- 1 | #ifndef _HSREGEX_H_ 2 | #define _HSREGEX_H_ 3 | #ifndef _HSREGEX_H 4 | #define _HSREGEX_H /* never again */ 5 | /* ========= begin header generated by ././mkh ========= */ 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* === regex2.h === */ 11 | #ifdef WIN32 12 | #define API_EXPORT(type) __declspec(dllexport) type __stdcall 13 | #elif defined(__GNUC__) && __GNUC__ >= 4 14 | #define API_EXPORT(type) __attribute__ ((visibility("default"))) type 15 | #else 16 | #define API_EXPORT(type) type 17 | #endif 18 | 19 | typedef off_t regoff_t; 20 | typedef struct { 21 | int re_magic; 22 | size_t re_nsub; /* number of parenthesized subexpressions */ 23 | const char *re_endp; /* end pointer for REG_PEND */ 24 | struct re_guts *re_g; /* none of your business :-) */ 25 | } regex_t; 26 | typedef struct { 27 | regoff_t rm_so; /* start of match */ 28 | regoff_t rm_eo; /* end of match */ 29 | } regmatch_t; 30 | 31 | 32 | /* === regcomp.c === */ 33 | API_EXPORT(int) regcomp(regex_t *, const char *, int); 34 | #define REG_BASIC 0000 35 | #define REG_EXTENDED 0001 36 | #define REG_ICASE 0002 37 | #define REG_NOSUB 0004 38 | #define REG_NEWLINE 0010 39 | #define REG_NOSPEC 0020 40 | #define REG_PEND 0040 41 | #define REG_DUMP 0200 42 | 43 | 44 | /* === regerror.c === */ 45 | #define REG_OKAY 0 46 | #define REG_NOMATCH 1 47 | #define REG_BADPAT 2 48 | #define REG_ECOLLATE 3 49 | #define REG_ECTYPE 4 50 | #define REG_EESCAPE 5 51 | #define REG_ESUBREG 6 52 | #define REG_EBRACK 7 53 | #define REG_EPAREN 8 54 | #define REG_EBRACE 9 55 | #define REG_BADBR 10 56 | #define REG_ERANGE 11 57 | #define REG_ESPACE 12 58 | #define REG_BADRPT 13 59 | #define REG_EMPTY 14 60 | #define REG_ASSERT 15 61 | #define REG_INVARG 16 62 | #define REG_ATOI 255 /* convert name to number (!) */ 63 | #define REG_ITOA 0400 /* convert number to name (!) */ 64 | API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t); 65 | 66 | 67 | /* === regexec.c === */ 68 | API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int); 69 | #define REG_NOTBOL 00001 70 | #define REG_NOTEOL 00002 71 | #define REG_STARTEND 00004 72 | #define REG_TRACE 00400 /* tracing of execution */ 73 | #define REG_LARGE 01000 /* force large representation */ 74 | #define REG_BACKR 02000 /* force use of backref code */ 75 | 76 | 77 | /* === regfree.c === */ 78 | API_EXPORT(void) regfree(regex_t *); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | /* ========= end header generated by ././mkh ========= */ 84 | #endif 85 | #endif 86 | -------------------------------------------------------------------------------- /regex/cname.h: -------------------------------------------------------------------------------- 1 | /* character-name table */ 2 | static const struct cname { 3 | const char *name; 4 | char code; 5 | } cnames[] = { 6 | {"NUL", '\0'}, 7 | {"SOH", '\001'}, 8 | {"STX", '\002'}, 9 | {"ETX", '\003'}, 10 | {"EOT", '\004'}, 11 | {"ENQ", '\005'}, 12 | {"ACK", '\006'}, 13 | {"BEL", '\007'}, 14 | {"alert", '\007'}, 15 | {"BS", '\010'}, 16 | {"backspace", '\b'}, 17 | {"HT", '\011'}, 18 | {"tab", '\t'}, 19 | {"LF", '\012'}, 20 | {"newline", '\n'}, 21 | {"VT", '\013'}, 22 | {"vertical-tab", '\v'}, 23 | {"FF", '\014'}, 24 | {"form-feed", '\f'}, 25 | {"CR", '\015'}, 26 | {"carriage-return", '\r'}, 27 | {"SO", '\016'}, 28 | {"SI", '\017'}, 29 | {"DLE", '\020'}, 30 | {"DC1", '\021'}, 31 | {"DC2", '\022'}, 32 | {"DC3", '\023'}, 33 | {"DC4", '\024'}, 34 | {"NAK", '\025'}, 35 | {"SYN", '\026'}, 36 | {"ETB", '\027'}, 37 | {"CAN", '\030'}, 38 | {"EM", '\031'}, 39 | {"SUB", '\032'}, 40 | {"ESC", '\033'}, 41 | {"IS4", '\034'}, 42 | {"FS", '\034'}, 43 | {"IS3", '\035'}, 44 | {"GS", '\035'}, 45 | {"IS2", '\036'}, 46 | {"RS", '\036'}, 47 | {"IS1", '\037'}, 48 | {"US", '\037'}, 49 | {"space", ' '}, 50 | {"exclamation-mark", '!'}, 51 | {"quotation-mark", '"'}, 52 | {"number-sign", '#'}, 53 | {"dollar-sign", '$'}, 54 | {"percent-sign", '%'}, 55 | {"ampersand", '&'}, 56 | {"apostrophe", '\''}, 57 | {"left-parenthesis", '('}, 58 | {"right-parenthesis", ')'}, 59 | {"asterisk", '*'}, 60 | {"plus-sign", '+'}, 61 | {"comma", ','}, 62 | {"hyphen", '-'}, 63 | {"hyphen-minus", '-'}, 64 | {"period", '.'}, 65 | {"full-stop", '.'}, 66 | {"slash", '/'}, 67 | {"solidus", '/'}, 68 | {"zero", '0'}, 69 | {"one", '1'}, 70 | {"two", '2'}, 71 | {"three", '3'}, 72 | {"four", '4'}, 73 | {"five", '5'}, 74 | {"six", '6'}, 75 | {"seven", '7'}, 76 | {"eight", '8'}, 77 | {"nine", '9'}, 78 | {"colon", ':'}, 79 | {"semicolon", ';'}, 80 | {"less-than-sign", '<'}, 81 | {"equals-sign", '='}, 82 | {"greater-than-sign", '>'}, 83 | {"question-mark", '?'}, 84 | {"commercial-at", '@'}, 85 | {"left-square-bracket", '['}, 86 | {"backslash", '\\'}, 87 | {"reverse-solidus", '\\'}, 88 | {"right-square-bracket", ']'}, 89 | {"circumflex", '^'}, 90 | {"circumflex-accent", '^'}, 91 | {"underscore", '_'}, 92 | {"low-line", '_'}, 93 | {"grave-accent", '`'}, 94 | {"left-brace", '{'}, 95 | {"left-curly-bracket", '{'}, 96 | {"vertical-line", '|'}, 97 | {"right-brace", '}'}, 98 | {"right-curly-bracket", '}'}, 99 | {"tilde", '~'}, 100 | {"DEL", '\177'}, 101 | {NULL, 0}, 102 | }; 103 | -------------------------------------------------------------------------------- /tests/ereg_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : basic functionality (without $regs) 3 | --FILE-- 4 | Pattern: '$pattern'; string: '$string'\n"; 22 | var_dump(ereg($pattern, $string)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing ereg() : basic functionality *** 29 | --> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---' 30 | 31 | Deprecated: Function ereg() is deprecated in %s on line %d 32 | int(1) 33 | --> Pattern: '()'; string: '' 34 | 35 | Deprecated: Function ereg() is deprecated in %s on line %d 36 | int(1) 37 | --> Pattern: '()'; string: 'abcdef' 38 | 39 | Deprecated: Function ereg() is deprecated in %s on line %d 40 | int(1) 41 | --> Pattern: '[x]|[^x]'; string: 'abcdef' 42 | 43 | Deprecated: Function ereg() is deprecated in %s on line %d 44 | int(1) 45 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---' 46 | 47 | Deprecated: Function ereg() is deprecated in %s on line %d 48 | int(1) 49 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{'' 50 | 51 | Deprecated: Function ereg() is deprecated in %s on line %d 52 | int(1) 53 | --> Pattern: '\a'; string: 'a' 54 | 55 | Deprecated: Function ereg() is deprecated in %s on line %d 56 | int(1) 57 | --> Pattern: '[0-9][^0-9]'; string: '2a' 58 | 59 | Deprecated: Function ereg() is deprecated in %s on line %d 60 | int(1) 61 | --> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 62 | 63 | Deprecated: Function ereg() is deprecated in %s on line %d 64 | int(1) 65 | --> Pattern: '^[[:digit:]]{5}'; string: '0123456789' 66 | 67 | Deprecated: Function ereg() is deprecated in %s on line %d 68 | int(1) 69 | --> Pattern: '[[:digit:]]{5}$'; string: '0123456789' 70 | 71 | Deprecated: Function ereg() is deprecated in %s on line %d 72 | int(1) 73 | --> Pattern: '[[:blank:]]{1,10}'; string: ' 74 | ' 75 | 76 | Deprecated: Function ereg() is deprecated in %s on line %d 77 | int(1) 78 | --> Pattern: '[[:print:]]{3}'; string: ' a ' 79 | 80 | Deprecated: Function ereg() is deprecated in %s on line %d 81 | int(1) 82 | Done 83 | -------------------------------------------------------------------------------- /tests/eregi_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : basic functionality (without $regs) 3 | --FILE-- 4 | Pattern: '$pattern'; string: '$string'\n"; 22 | var_dump(eregi($pattern, $string)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing eregi() : basic functionality *** 29 | --> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---' 30 | 31 | Deprecated: Function eregi() is deprecated in %s on line %d 32 | int(1) 33 | --> Pattern: '()'; string: '' 34 | 35 | Deprecated: Function eregi() is deprecated in %s on line %d 36 | int(1) 37 | --> Pattern: '()'; string: 'abcdef' 38 | 39 | Deprecated: Function eregi() is deprecated in %s on line %d 40 | int(1) 41 | --> Pattern: '[x]|[^x]'; string: 'abcdef' 42 | 43 | Deprecated: Function eregi() is deprecated in %s on line %d 44 | int(1) 45 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---' 46 | 47 | Deprecated: Function eregi() is deprecated in %s on line %d 48 | int(1) 49 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{'' 50 | 51 | Deprecated: Function eregi() is deprecated in %s on line %d 52 | int(1) 53 | --> Pattern: '\a'; string: 'a' 54 | 55 | Deprecated: Function eregi() is deprecated in %s on line %d 56 | int(1) 57 | --> Pattern: '[0-9][^0-9]'; string: '2a' 58 | 59 | Deprecated: Function eregi() is deprecated in %s on line %d 60 | int(1) 61 | --> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 62 | 63 | Deprecated: Function eregi() is deprecated in %s on line %d 64 | int(1) 65 | --> Pattern: '^[[:digit:]]{5}'; string: '0123456789' 66 | 67 | Deprecated: Function eregi() is deprecated in %s on line %d 68 | int(1) 69 | --> Pattern: '[[:digit:]]{5}$'; string: '0123456789' 70 | 71 | Deprecated: Function eregi() is deprecated in %s on line %d 72 | int(1) 73 | --> Pattern: '[[:blank:]]{1,10}'; string: ' 74 | ' 75 | 76 | Deprecated: Function eregi() is deprecated in %s on line %d 77 | int(1) 78 | --> Pattern: '[[:print:]]{3}'; string: ' a ' 79 | 80 | Deprecated: Function eregi() is deprecated in %s on line %d 81 | int(1) 82 | Done 83 | -------------------------------------------------------------------------------- /regex/regcomp.ih: -------------------------------------------------------------------------------- 1 | /* ========= begin header generated by ./mkh ========= */ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* === regcomp.c === */ 7 | static void p_ere(register struct parse *p, int stop); 8 | static void p_ere_exp(register struct parse *p); 9 | static void p_str(register struct parse *p); 10 | static void p_bre(register struct parse *p, register int end1, register int end2); 11 | static int p_simp_re(register struct parse *p, int starordinary); 12 | static int p_count(register struct parse *p); 13 | static void p_bracket(register struct parse *p); 14 | static void p_b_term(register struct parse *p, register cset *cs); 15 | static void p_b_cclass(register struct parse *p, register cset *cs); 16 | static void p_b_eclass(register struct parse *p, register cset *cs); 17 | static unsigned char p_b_symbol(register struct parse *p); 18 | static unsigned char p_b_coll_elem(register struct parse *p, int endc); 19 | static unsigned char othercase(int ch); 20 | static void bothcases(register struct parse *p, int ch); 21 | static void ordinary(register struct parse *p, register int ch); 22 | static void nonnewline(register struct parse *p); 23 | static void repeat(register struct parse *p, sopno start, int from, int to); 24 | static int seterr(register struct parse *p, int e); 25 | static cset *allocset(register struct parse *p); 26 | static void freeset(register struct parse *p, register cset *cs); 27 | static int freezeset(register struct parse *p, register cset *cs); 28 | static int firstch(register struct parse *p, register cset *cs); 29 | static int nch(register struct parse *p, register cset *cs); 30 | static void mcadd(register struct parse *p, register cset *cs, register const unsigned char *cp); 31 | #if 0 32 | static void mcsub(register cset *cs, register unsigned char *cp); 33 | static int mcin(register cset *cs, register unsigned char *cp); 34 | static unsigned char *mcfind(register cset *cs, register unsigned char *cp); 35 | #endif 36 | static void mcinvert(register struct parse *p, register cset *cs); 37 | static void mccase(register struct parse *p, register cset *cs); 38 | static int isinsets(register struct re_guts *g, int c); 39 | static int samesets(register struct re_guts *g, int c1, int c2); 40 | static void categorize(struct parse *p, register struct re_guts *g); 41 | static sopno dupl(register struct parse *p, sopno start, sopno finish); 42 | static void doemit(register struct parse *p, sop op, size_t opnd); 43 | static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos); 44 | static void dofwd(register struct parse *p, sopno pos, sop value); 45 | static void enlarge(register struct parse *p, sopno size); 46 | static void stripsnug(register struct parse *p, register struct re_guts *g); 47 | static void findmust(register struct parse *p, register struct re_guts *g); 48 | static sopno pluscount(register struct parse *p, register struct re_guts *g); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | /* ========= end header generated by ./mkh ========= */ 54 | -------------------------------------------------------------------------------- /tests/ereg_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : error conditions - test bad regular expressions 3 | --FILE-- 4 | 40 | --EXPECTF-- 41 | *** Testing ereg() : error conditions *** 42 | 43 | Deprecated: Function ereg() is deprecated in %s on line %d 44 | 45 | Warning: ereg(): REG_EMPTY in %s on line %d 46 | bool(false) 47 | 48 | Deprecated: Function ereg() is deprecated in %s on line %d 49 | 50 | Warning: ereg(): REG_EPAREN in %s on line %d 51 | bool(false) 52 | 53 | Deprecated: Function ereg() is deprecated in %s on line %d 54 | 55 | Warning: ereg(): REG_EBRACK in %s on line %d 56 | bool(false) 57 | 58 | Deprecated: Function ereg() is deprecated in %s on line %d 59 | 60 | Warning: ereg(): REG_EPAREN in %s on line %d 61 | bool(false) 62 | 63 | Deprecated: Function ereg() is deprecated in %s on line %d 64 | 65 | Warning: ereg(): REG_BADRPT in %s on line %d 66 | bool(false) 67 | 68 | Deprecated: Function ereg() is deprecated in %s on line %d 69 | 70 | Warning: ereg(): REG_BADRPT in %s on line %d 71 | bool(false) 72 | 73 | Deprecated: Function ereg() is deprecated in %s on line %d 74 | 75 | Warning: ereg(): REG_BADRPT in %s on line %d 76 | bool(false) 77 | 78 | Deprecated: Function ereg() is deprecated in %s on line %d 79 | 80 | Warning: ereg(): REG_BADRPT in %s on line %d 81 | bool(false) 82 | 83 | Deprecated: Function ereg() is deprecated in %s on line %d 84 | 85 | Warning: ereg(): REG_BADBR in %s on line %d 86 | bool(false) 87 | 88 | Deprecated: Function ereg() is deprecated in %s on line %d 89 | 90 | Warning: ereg(): REG_EMPTY in %s on line %d 91 | bool(false) 92 | 93 | Deprecated: Function ereg() is deprecated in %s on line %d 94 | 95 | Warning: ereg(): REG_EMPTY in %s on line %d 96 | bool(false) 97 | 98 | Deprecated: Function ereg() is deprecated in %s on line %d 99 | 100 | Warning: ereg(): REG_BADBR in %s on line %d 101 | bool(false) 102 | 103 | Deprecated: Function ereg() is deprecated in %s on line %d 104 | 105 | Warning: ereg(): REG_ERANGE in %s on line %d 106 | bool(false) 107 | 108 | Deprecated: Function ereg() is deprecated in %s on line %d 109 | 110 | Warning: ereg(): REG_EESCAPE in %s on line %d 111 | bool(false) 112 | 113 | Deprecated: Function ereg() is deprecated in %s on line %d 114 | 115 | Warning: ereg(): REG_ERANGE in %s on line %d 116 | bool(false) 117 | string(8) "original" 118 | Done 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | The PHP License, version 3.01 3 | Copyright (c) 1999 - 2015 The PHP Group. All rights reserved. 4 | -------------------------------------------------------------------- 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, is permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | 3. The name "PHP" must not be used to endorse or promote products 19 | derived from this software without prior written permission. For 20 | written permission, please contact group@php.net. 21 | 22 | 4. Products derived from this software may not be called "PHP", nor 23 | may "PHP" appear in their name, without prior written permission 24 | from group@php.net. You may indicate that your software works in 25 | conjunction with PHP by saying "Foo for PHP" instead of calling 26 | it "PHP Foo" or "phpfoo" 27 | 28 | 5. The PHP Group may publish revised and/or new versions of the 29 | license from time to time. Each version will be given a 30 | distinguishing version number. 31 | Once covered code has been published under a particular version 32 | of the license, you may always continue to use it under the terms 33 | of that version. You may also choose to use such covered code 34 | under the terms of any subsequent version of the license 35 | published by the PHP Group. No one other than the PHP Group has 36 | the right to modify the terms applicable to covered code created 37 | under this License. 38 | 39 | 6. Redistributions of any form whatsoever must retain the following 40 | acknowledgment: 41 | "This product includes PHP software, freely available from 42 | ". 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55 | OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | -------------------------------------------------------------------- 58 | 59 | This software consists of voluntary contributions made by many 60 | individuals on behalf of the PHP Group. 61 | 62 | The PHP Group can be contacted via Email at group@php.net. 63 | 64 | For more information on the PHP Group and the PHP project, 65 | please see . 66 | 67 | PHP includes the Zend Engine, freely available at 68 | . 69 | -------------------------------------------------------------------------------- /tests/eregi_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : error conditions - test bad regular expressions 3 | --FILE-- 4 | 40 | --EXPECTF-- 41 | *** Testing eregi() : error conditions *** 42 | 43 | Deprecated: Function eregi() is deprecated in %s on line %d 44 | 45 | Warning: eregi(): REG_EMPTY in %s on line %d 46 | bool(false) 47 | 48 | Deprecated: Function eregi() is deprecated in %s on line %d 49 | 50 | Warning: eregi(): REG_EPAREN in %s on line %d 51 | bool(false) 52 | 53 | Deprecated: Function eregi() is deprecated in %s on line %d 54 | 55 | Warning: eregi(): REG_EBRACK in %s on line %d 56 | bool(false) 57 | 58 | Deprecated: Function eregi() is deprecated in %s on line %d 59 | 60 | Warning: eregi(): REG_EPAREN in %s on line %d 61 | bool(false) 62 | 63 | Deprecated: Function eregi() is deprecated in %s on line %d 64 | 65 | Warning: eregi(): REG_BADRPT in %s on line %d 66 | bool(false) 67 | 68 | Deprecated: Function eregi() is deprecated in %s on line %d 69 | 70 | Warning: eregi(): REG_BADRPT in %s on line %d 71 | bool(false) 72 | 73 | Deprecated: Function eregi() is deprecated in %s on line %d 74 | 75 | Warning: eregi(): REG_BADRPT in %s on line %d 76 | bool(false) 77 | 78 | Deprecated: Function eregi() is deprecated in %s on line %d 79 | 80 | Warning: eregi(): REG_BADRPT in %s on line %d 81 | bool(false) 82 | 83 | Deprecated: Function eregi() is deprecated in %s on line %d 84 | 85 | Warning: eregi(): REG_BADBR in %s on line %d 86 | bool(false) 87 | 88 | Deprecated: Function eregi() is deprecated in %s on line %d 89 | 90 | Warning: eregi(): REG_EMPTY in %s on line %d 91 | bool(false) 92 | 93 | Deprecated: Function eregi() is deprecated in %s on line %d 94 | 95 | Warning: eregi(): REG_EMPTY in %s on line %d 96 | bool(false) 97 | 98 | Deprecated: Function eregi() is deprecated in %s on line %d 99 | 100 | Warning: eregi(): REG_BADBR in %s on line %d 101 | bool(false) 102 | 103 | Deprecated: Function eregi() is deprecated in %s on line %d 104 | 105 | Warning: eregi(): REG_ERANGE in %s on line %d 106 | bool(false) 107 | 108 | Deprecated: Function eregi() is deprecated in %s on line %d 109 | 110 | Warning: eregi(): REG_EESCAPE in %s on line %d 111 | bool(false) 112 | 113 | Deprecated: Function eregi() is deprecated in %s on line %d 114 | 115 | Warning: eregi(): REG_ERANGE in %s on line %d 116 | bool(false) 117 | string(8) "original" 118 | Done 119 | -------------------------------------------------------------------------------- /tests/split_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : error conditions - test bad regular expressions 3 | --FILE-- 4 | 40 | --EXPECTF-- 41 | *** Testing split() : error conditions *** 42 | 43 | Deprecated: Function split() is deprecated in %s on line %d 44 | 45 | Warning: split(): REG_EMPTY in %s on line %d 46 | bool(false) 47 | 48 | Deprecated: Function split() is deprecated in %s on line %d 49 | 50 | Warning: split(): REG_EPAREN in %s on line %d 51 | bool(false) 52 | 53 | Deprecated: Function split() is deprecated in %s on line %d 54 | 55 | Warning: split(): REG_EBRACK in %s on line %d 56 | bool(false) 57 | 58 | Deprecated: Function split() is deprecated in %s on line %d 59 | 60 | Warning: split(): REG_EPAREN in %s on line %d 61 | bool(false) 62 | 63 | Deprecated: Function split() is deprecated in %s on line %d 64 | 65 | Warning: split(): REG_BADRPT in %s on line %d 66 | bool(false) 67 | 68 | Deprecated: Function split() is deprecated in %s on line %d 69 | 70 | Warning: split(): REG_BADRPT in %s on line %d 71 | bool(false) 72 | 73 | Deprecated: Function split() is deprecated in %s on line %d 74 | 75 | Warning: split(): REG_BADRPT in %s on line %d 76 | bool(false) 77 | 78 | Deprecated: Function split() is deprecated in %s on line %d 79 | 80 | Warning: split() expects parameter 3 to be integer, string given in %s on line %d 81 | NULL 82 | 83 | Deprecated: Function split() is deprecated in %s on line %d 84 | 85 | Warning: split(): REG_BADBR in %s on line %d 86 | bool(false) 87 | 88 | Deprecated: Function split() is deprecated in %s on line %d 89 | 90 | Warning: split(): REG_EMPTY in %s on line %d 91 | bool(false) 92 | 93 | Deprecated: Function split() is deprecated in %s on line %d 94 | 95 | Warning: split(): REG_EMPTY in %s on line %d 96 | bool(false) 97 | 98 | Deprecated: Function split() is deprecated in %s on line %d 99 | 100 | Warning: split(): REG_BADBR in %s on line %d 101 | bool(false) 102 | 103 | Deprecated: Function split() is deprecated in %s on line %d 104 | 105 | Warning: split(): REG_ERANGE in %s on line %d 106 | bool(false) 107 | 108 | Deprecated: Function split() is deprecated in %s on line %d 109 | 110 | Warning: split(): REG_EESCAPE in %s on line %d 111 | bool(false) 112 | 113 | Deprecated: Function split() is deprecated in %s on line %d 114 | 115 | Warning: split() expects parameter 3 to be integer, string given in %s on line %d 116 | NULL 117 | string(8) "original" 118 | Done 119 | -------------------------------------------------------------------------------- /tests/spliti_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : error conditions - test bad regular expressions 3 | --FILE-- 4 | 40 | --EXPECTF-- 41 | *** Testing spliti() : error conditions *** 42 | 43 | Deprecated: Function spliti() is deprecated in %s on line %d 44 | 45 | Warning: spliti(): REG_EMPTY in %s on line %d 46 | bool(false) 47 | 48 | Deprecated: Function spliti() is deprecated in %s on line %d 49 | 50 | Warning: spliti(): REG_EPAREN in %s on line %d 51 | bool(false) 52 | 53 | Deprecated: Function spliti() is deprecated in %s on line %d 54 | 55 | Warning: spliti(): REG_EBRACK in %s on line %d 56 | bool(false) 57 | 58 | Deprecated: Function spliti() is deprecated in %s on line %d 59 | 60 | Warning: spliti(): REG_EPAREN in %s on line %d 61 | bool(false) 62 | 63 | Deprecated: Function spliti() is deprecated in %s on line %d 64 | 65 | Warning: spliti(): REG_BADRPT in %s on line %d 66 | bool(false) 67 | 68 | Deprecated: Function spliti() is deprecated in %s on line %d 69 | 70 | Warning: spliti(): REG_BADRPT in %s on line %d 71 | bool(false) 72 | 73 | Deprecated: Function spliti() is deprecated in %s on line %d 74 | 75 | Warning: spliti(): REG_BADRPT in %s on line %d 76 | bool(false) 77 | 78 | Deprecated: Function spliti() is deprecated in %s on line %d 79 | 80 | Warning: spliti() expects parameter 3 to be integer, string given in %s on line %d 81 | NULL 82 | 83 | Deprecated: Function spliti() is deprecated in %s on line %d 84 | 85 | Warning: spliti(): REG_BADBR in %s on line %d 86 | bool(false) 87 | 88 | Deprecated: Function spliti() is deprecated in %s on line %d 89 | 90 | Warning: spliti(): REG_EMPTY in %s on line %d 91 | bool(false) 92 | 93 | Deprecated: Function spliti() is deprecated in %s on line %d 94 | 95 | Warning: spliti(): REG_EMPTY in %s on line %d 96 | bool(false) 97 | 98 | Deprecated: Function spliti() is deprecated in %s on line %d 99 | 100 | Warning: spliti(): REG_BADBR in %s on line %d 101 | bool(false) 102 | 103 | Deprecated: Function spliti() is deprecated in %s on line %d 104 | 105 | Warning: spliti(): REG_ERANGE in %s on line %d 106 | bool(false) 107 | 108 | Deprecated: Function spliti() is deprecated in %s on line %d 109 | 110 | Warning: spliti(): REG_EESCAPE in %s on line %d 111 | bool(false) 112 | 113 | Deprecated: Function spliti() is deprecated in %s on line %d 114 | 115 | Warning: spliti() expects parameter 3 to be integer, string given in %s on line %d 116 | NULL 117 | string(8) "original" 118 | Done 119 | -------------------------------------------------------------------------------- /tests/ereg_replace_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : error conditions - bad regular expressions 3 | --FILE-- 4 | 29 | --EXPECTF-- 30 | *** Testing ereg_replace() : bad REs *** 31 | 32 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 33 | 34 | Warning: ereg_replace(): REG_EMPTY in %s on line %d 35 | bool(false) 36 | 37 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 38 | 39 | Warning: ereg_replace(): REG_EPAREN in %s on line %d 40 | bool(false) 41 | 42 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 43 | 44 | Warning: ereg_replace(): REG_EBRACK in %s on line %d 45 | bool(false) 46 | 47 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 48 | 49 | Warning: ereg_replace(): REG_EPAREN in %s on line %d 50 | bool(false) 51 | 52 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 53 | 54 | Warning: ereg_replace(): REG_BADRPT in %s on line %d 55 | bool(false) 56 | 57 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 58 | 59 | Warning: ereg_replace(): REG_BADRPT in %s on line %d 60 | bool(false) 61 | 62 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 63 | 64 | Warning: ereg_replace(): REG_BADRPT in %s on line %d 65 | bool(false) 66 | 67 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 68 | 69 | Warning: ereg_replace(): REG_BADRPT in %s on line %d 70 | bool(false) 71 | 72 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 73 | 74 | Warning: ereg_replace(): REG_BADBR in %s on line %d 75 | bool(false) 76 | 77 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 78 | 79 | Warning: ereg_replace(): REG_EMPTY in %s on line %d 80 | bool(false) 81 | 82 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 83 | 84 | Warning: ereg_replace(): REG_EMPTY in %s on line %d 85 | bool(false) 86 | 87 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 88 | 89 | Warning: ereg_replace(): REG_BADBR in %s on line %d 90 | bool(false) 91 | 92 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 93 | 94 | Warning: ereg_replace(): REG_ERANGE in %s on line %d 95 | bool(false) 96 | 97 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 98 | 99 | Warning: ereg_replace(): REG_EESCAPE in %s on line %d 100 | bool(false) 101 | 102 | Deprecated: Function ereg_replace() is deprecated in %s on line %d 103 | 104 | Warning: ereg_replace(): REG_ERANGE in %s on line %d 105 | bool(false) 106 | Done 107 | -------------------------------------------------------------------------------- /tests/eregi_replace_error_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : error conditions - bad regular expressions 3 | --FILE-- 4 | 29 | --EXPECTF-- 30 | *** Testing eregi_replace() : bad REs *** 31 | 32 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 33 | 34 | Warning: eregi_replace(): REG_EMPTY in %s on line %d 35 | bool(false) 36 | 37 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 38 | 39 | Warning: eregi_replace(): REG_EPAREN in %s on line %d 40 | bool(false) 41 | 42 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 43 | 44 | Warning: eregi_replace(): REG_EBRACK in %s on line %d 45 | bool(false) 46 | 47 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 48 | 49 | Warning: eregi_replace(): REG_EPAREN in %s on line %d 50 | bool(false) 51 | 52 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 53 | 54 | Warning: eregi_replace(): REG_BADRPT in %s on line %d 55 | bool(false) 56 | 57 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 58 | 59 | Warning: eregi_replace(): REG_BADRPT in %s on line %d 60 | bool(false) 61 | 62 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 63 | 64 | Warning: eregi_replace(): REG_BADRPT in %s on line %d 65 | bool(false) 66 | 67 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 68 | 69 | Warning: eregi_replace(): REG_BADRPT in %s on line %d 70 | bool(false) 71 | 72 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 73 | 74 | Warning: eregi_replace(): REG_BADBR in %s on line %d 75 | bool(false) 76 | 77 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 78 | 79 | Warning: eregi_replace(): REG_EMPTY in %s on line %d 80 | bool(false) 81 | 82 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 83 | 84 | Warning: eregi_replace(): REG_EMPTY in %s on line %d 85 | bool(false) 86 | 87 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 88 | 89 | Warning: eregi_replace(): REG_BADBR in %s on line %d 90 | bool(false) 91 | 92 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 93 | 94 | Warning: eregi_replace(): REG_ERANGE in %s on line %d 95 | bool(false) 96 | 97 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 98 | 99 | Warning: eregi_replace(): REG_EESCAPE in %s on line %d 100 | bool(false) 101 | 102 | Deprecated: Function eregi_replace() is deprecated in %s on line %d 103 | 104 | Warning: eregi_replace(): REG_ERANGE in %s on line %d 105 | bool(false) 106 | Done 107 | -------------------------------------------------------------------------------- /tests/ereg_basic_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : basic functionality (with $regs) 3 | --FILE-- 4 | Pattern: '$pattern'; string: '$string'\n"; 22 | var_dump(ereg($pattern, $string, $regs)); 23 | var_dump($regs); 24 | } 25 | 26 | echo "Done"; 27 | ?> 28 | --EXPECTF-- 29 | *** Testing ereg() : basic functionality *** 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---' 31 | 32 | Deprecated: Function ereg() is deprecated in %s on line %d 33 | int(6) 34 | array(3) { 35 | [0]=> 36 | string(6) "- ab -" 37 | [1]=> 38 | string(1) "a" 39 | [2]=> 40 | string(1) "b" 41 | } 42 | --> Pattern: '()'; string: '' 43 | 44 | Deprecated: Function ereg() is deprecated in %s on line %d 45 | int(1) 46 | array(2) { 47 | [0]=> 48 | bool(false) 49 | [1]=> 50 | bool(false) 51 | } 52 | --> Pattern: '()'; string: 'abcdef' 53 | 54 | Deprecated: Function ereg() is deprecated in %s on line %d 55 | int(1) 56 | array(2) { 57 | [0]=> 58 | bool(false) 59 | [1]=> 60 | bool(false) 61 | } 62 | --> Pattern: '[x]|[^x]'; string: 'abcdef' 63 | 64 | Deprecated: Function ereg() is deprecated in %s on line %d 65 | int(1) 66 | array(1) { 67 | [0]=> 68 | string(1) "a" 69 | } 70 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---' 71 | 72 | Deprecated: Function ereg() is deprecated in %s on line %d 73 | int(15) 74 | array(6) { 75 | [0]=> 76 | string(15) "aaa bbb ccc ddd" 77 | [1]=> 78 | string(1) "a" 79 | [2]=> 80 | string(2) "aa" 81 | [3]=> 82 | string(3) "bbb" 83 | [4]=> 84 | string(3) "ccc" 85 | [5]=> 86 | string(3) "ddd" 87 | } 88 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{'' 89 | 90 | Deprecated: Function ereg() is deprecated in %s on line %d 91 | int(14) 92 | array(1) { 93 | [0]=> 94 | string(14) "\`^.[$()|*+?{'" 95 | } 96 | --> Pattern: '\a'; string: 'a' 97 | 98 | Deprecated: Function ereg() is deprecated in %s on line %d 99 | int(1) 100 | array(1) { 101 | [0]=> 102 | string(1) "a" 103 | } 104 | --> Pattern: '[0-9][^0-9]'; string: '2a' 105 | 106 | Deprecated: Function ereg() is deprecated in %s on line %d 107 | int(2) 108 | array(1) { 109 | [0]=> 110 | string(2) "2a" 111 | } 112 | --> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 113 | 114 | Deprecated: Function ereg() is deprecated in %s on line %d 115 | int(62) 116 | array(1) { 117 | [0]=> 118 | string(62) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 119 | } 120 | --> Pattern: '^[[:digit:]]{5}'; string: '0123456789' 121 | 122 | Deprecated: Function ereg() is deprecated in %s on line %d 123 | int(5) 124 | array(1) { 125 | [0]=> 126 | string(5) "01234" 127 | } 128 | --> Pattern: '[[:digit:]]{5}$'; string: '0123456789' 129 | 130 | Deprecated: Function ereg() is deprecated in %s on line %d 131 | int(5) 132 | array(1) { 133 | [0]=> 134 | string(5) "56789" 135 | } 136 | --> Pattern: '[[:blank:]]{1,10}'; string: ' 137 | ' 138 | 139 | Deprecated: Function ereg() is deprecated in %s on line %d 140 | int(2) 141 | array(1) { 142 | [0]=> 143 | string(2) " " 144 | } 145 | --> Pattern: '[[:print:]]{3}'; string: ' a ' 146 | 147 | Deprecated: Function ereg() is deprecated in %s on line %d 148 | int(3) 149 | array(1) { 150 | [0]=> 151 | string(3) " a " 152 | } 153 | Done 154 | -------------------------------------------------------------------------------- /tests/eregi_basic_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : basic functionality (with $regs) 3 | --FILE-- 4 | Pattern: '$pattern'; string: '$string'\n"; 22 | var_dump(eregi($pattern, $string, $regs)); 23 | var_dump($regs); 24 | } 25 | 26 | echo "Done"; 27 | ?> 28 | --EXPECTF-- 29 | *** Testing eregi() : basic functionality *** 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---' 31 | 32 | Deprecated: Function eregi() is deprecated in %s on line %d 33 | int(6) 34 | array(3) { 35 | [0]=> 36 | string(6) "- ab -" 37 | [1]=> 38 | string(1) "a" 39 | [2]=> 40 | string(1) "b" 41 | } 42 | --> Pattern: '()'; string: '' 43 | 44 | Deprecated: Function eregi() is deprecated in %s on line %d 45 | int(1) 46 | array(2) { 47 | [0]=> 48 | bool(false) 49 | [1]=> 50 | bool(false) 51 | } 52 | --> Pattern: '()'; string: 'abcdef' 53 | 54 | Deprecated: Function eregi() is deprecated in %s on line %d 55 | int(1) 56 | array(2) { 57 | [0]=> 58 | bool(false) 59 | [1]=> 60 | bool(false) 61 | } 62 | --> Pattern: '[x]|[^x]'; string: 'abcdef' 63 | 64 | Deprecated: Function eregi() is deprecated in %s on line %d 65 | int(1) 66 | array(1) { 67 | [0]=> 68 | string(1) "a" 69 | } 70 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---' 71 | 72 | Deprecated: Function eregi() is deprecated in %s on line %d 73 | int(15) 74 | array(6) { 75 | [0]=> 76 | string(15) "aaa bbb ccc ddd" 77 | [1]=> 78 | string(1) "a" 79 | [2]=> 80 | string(2) "aa" 81 | [3]=> 82 | string(3) "bbb" 83 | [4]=> 84 | string(3) "ccc" 85 | [5]=> 86 | string(3) "ddd" 87 | } 88 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{'' 89 | 90 | Deprecated: Function eregi() is deprecated in %s on line %d 91 | int(14) 92 | array(1) { 93 | [0]=> 94 | string(14) "\`^.[$()|*+?{'" 95 | } 96 | --> Pattern: '\a'; string: 'a' 97 | 98 | Deprecated: Function eregi() is deprecated in %s on line %d 99 | int(1) 100 | array(1) { 101 | [0]=> 102 | string(1) "a" 103 | } 104 | --> Pattern: '[0-9][^0-9]'; string: '2a' 105 | 106 | Deprecated: Function eregi() is deprecated in %s on line %d 107 | int(2) 108 | array(1) { 109 | [0]=> 110 | string(2) "2a" 111 | } 112 | --> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 113 | 114 | Deprecated: Function eregi() is deprecated in %s on line %d 115 | int(62) 116 | array(1) { 117 | [0]=> 118 | string(62) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 119 | } 120 | --> Pattern: '^[[:digit:]]{5}'; string: '0123456789' 121 | 122 | Deprecated: Function eregi() is deprecated in %s on line %d 123 | int(5) 124 | array(1) { 125 | [0]=> 126 | string(5) "01234" 127 | } 128 | --> Pattern: '[[:digit:]]{5}$'; string: '0123456789' 129 | 130 | Deprecated: Function eregi() is deprecated in %s on line %d 131 | int(5) 132 | array(1) { 133 | [0]=> 134 | string(5) "56789" 135 | } 136 | --> Pattern: '[[:blank:]]{1,10}'; string: ' 137 | ' 138 | 139 | Deprecated: Function eregi() is deprecated in %s on line %d 140 | int(2) 141 | array(1) { 142 | [0]=> 143 | string(2) " " 144 | } 145 | --> Pattern: '[[:print:]]{3}'; string: ' a ' 146 | 147 | Deprecated: Function eregi() is deprecated in %s on line %d 148 | int(3) 149 | array(1) { 150 | [0]=> 151 | string(3) " a " 152 | } 153 | Done 154 | -------------------------------------------------------------------------------- /regex/regerror.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "regex.h" 9 | #include "utils.h" 10 | #include "regerror.ih" 11 | #include "php.h" 12 | 13 | /* 14 | = #define REG_OKAY 0 15 | = #define REG_NOMATCH 1 16 | = #define REG_BADPAT 2 17 | = #define REG_ECOLLATE 3 18 | = #define REG_ECTYPE 4 19 | = #define REG_EESCAPE 5 20 | = #define REG_ESUBREG 6 21 | = #define REG_EBRACK 7 22 | = #define REG_EPAREN 8 23 | = #define REG_EBRACE 9 24 | = #define REG_BADBR 10 25 | = #define REG_ERANGE 11 26 | = #define REG_ESPACE 12 27 | = #define REG_BADRPT 13 28 | = #define REG_EMPTY 14 29 | = #define REG_ASSERT 15 30 | = #define REG_INVARG 16 31 | = #define REG_ATOI 255 // convert name to number (!) 32 | = #define REG_ITOA 0400 // convert number to name (!) 33 | */ 34 | static const struct rerr { 35 | int code; 36 | const char *name; 37 | const char *explain; 38 | } rerrs[] = { 39 | {REG_OKAY, "REG_OKAY", "no errors detected"}, 40 | {REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match"}, 41 | {REG_BADPAT, "REG_BADPAT", "invalid regular expression"}, 42 | {REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element"}, 43 | {REG_ECTYPE, "REG_ECTYPE", "invalid character class"}, 44 | {REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)"}, 45 | {REG_ESUBREG, "REG_ESUBREG", "invalid backreference number"}, 46 | {REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced"}, 47 | {REG_EPAREN, "REG_EPAREN", "parentheses not balanced"}, 48 | {REG_EBRACE, "REG_EBRACE", "braces not balanced"}, 49 | {REG_BADBR, "REG_BADBR", "invalid repetition count(s)"}, 50 | {REG_ERANGE, "REG_ERANGE", "invalid character range"}, 51 | {REG_ESPACE, "REG_ESPACE", "out of memory"}, 52 | {REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid"}, 53 | {REG_EMPTY, "REG_EMPTY", "empty (sub)expression"}, 54 | {REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug"}, 55 | {REG_INVARG, "REG_INVARG", "invalid argument to regex routine"}, 56 | {-1, "", "*** unknown regexp error code ***"}, 57 | }; 58 | 59 | /* 60 | - regerror - the interface to error numbers 61 | = API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t); 62 | */ 63 | /* ARGSUSED */ 64 | API_EXPORT(size_t) 65 | regerror( 66 | int errcode, 67 | const regex_t *preg, 68 | char *errbuf, 69 | size_t errbuf_size) 70 | { 71 | register const struct rerr *r; 72 | register size_t len; 73 | register int target = errcode &~ REG_ITOA; 74 | register const char *s; 75 | char convbuf[50]; 76 | 77 | if (errcode == REG_ATOI) 78 | s = regatoi(preg, convbuf, sizeof(convbuf)); 79 | else { 80 | for (r = rerrs; r->code >= 0; r++) 81 | if (r->code == target) 82 | break; 83 | 84 | if (errcode®_ITOA) { 85 | if (r->code >= 0) { 86 | (void) strncpy(convbuf, r->name, sizeof(convbuf) - 1); 87 | convbuf[sizeof(convbuf) - 1] = '\0'; 88 | } else { 89 | snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target); 90 | } 91 | assert(strlen(convbuf) < sizeof(convbuf)); 92 | s = convbuf; 93 | } else 94 | s = r->explain; 95 | } 96 | 97 | len = strlen(s) + 1; 98 | if (errbuf_size > 0) { 99 | if (errbuf_size > len) 100 | (void) strcpy(errbuf, s); 101 | else { 102 | (void) strncpy(errbuf, s, errbuf_size-1); 103 | errbuf[errbuf_size-1] = '\0'; 104 | } 105 | } 106 | 107 | return(len); 108 | } 109 | 110 | /* 111 | - regatoi - internal routine to implement REG_ATOI 112 | == static char *regatoi(const regex_t *preg, char *localbuf, int bufsize); 113 | */ 114 | static char * 115 | regatoi(preg, localbuf, bufsize) 116 | const regex_t *preg; 117 | char *localbuf; 118 | int bufsize; 119 | { 120 | register const struct rerr *r; 121 | 122 | for (r = rerrs; r->code >= 0; r++) 123 | if (strcmp(r->name, preg->re_endp) == 0) 124 | break; 125 | if (r->code < 0) 126 | return("0"); 127 | 128 | snprintf(localbuf, bufsize, "%d", r->code); 129 | return(localbuf); 130 | } 131 | -------------------------------------------------------------------------------- /tests/split_basic_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : basic functionality - test a number of simple split, specifying a limit 3 | --FILE-- 4 | Pattern: '$pattern'; match: '$string'\n"; 22 | var_dump(split($pattern, $string . ' |1| ' . $string . ' |2| ' . $string, 2)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing ereg() : basic functionality *** 29 | 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---' 31 | 32 | Deprecated: Function split() is deprecated in %s on line %d 33 | array(2) { 34 | [0]=> 35 | string(2) "--" 36 | [1]=> 37 | string(32) "-- |1| --- ab --- |2| --- ab ---" 38 | } 39 | 40 | --> Pattern: '()'; match: '' 41 | 42 | Deprecated: Function split() is deprecated in %s on line %d 43 | 44 | Warning: split(): Invalid Regular Expression in %s on line %d 45 | bool(false) 46 | 47 | --> Pattern: '()'; match: 'abcdef' 48 | 49 | Deprecated: Function split() is deprecated in %s on line %d 50 | 51 | Warning: split(): Invalid Regular Expression in %s on line %d 52 | bool(false) 53 | 54 | --> Pattern: '[x]|[^x]'; match: 'abcdef' 55 | 56 | Deprecated: Function split() is deprecated in %s on line %d 57 | array(2) { 58 | [0]=> 59 | string(0) "" 60 | [1]=> 61 | string(27) "bcdef |1| abcdef |2| abcdef" 62 | } 63 | 64 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---' 65 | 66 | Deprecated: Function split() is deprecated in %s on line %d 67 | array(2) { 68 | [0]=> 69 | string(4) "--- " 70 | [1]=> 71 | string(60) " --- |1| --- aaa bbb ccc ddd --- |2| --- aaa bbb ccc ddd ---" 72 | } 73 | 74 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{'' 75 | 76 | Deprecated: Function split() is deprecated in %s on line %d 77 | array(2) { 78 | [0]=> 79 | string(0) "" 80 | [1]=> 81 | string(38) " |1| \`^.[$()|*+?{' |2| \`^.[$()|*+?{'" 82 | } 83 | 84 | --> Pattern: '\a'; match: 'a' 85 | 86 | Deprecated: Function split() is deprecated in %s on line %d 87 | array(2) { 88 | [0]=> 89 | string(0) "" 90 | [1]=> 91 | string(12) " |1| a |2| a" 92 | } 93 | 94 | --> Pattern: '[0-9][^0-9]'; match: '2a' 95 | 96 | Deprecated: Function split() is deprecated in %s on line %d 97 | array(2) { 98 | [0]=> 99 | string(0) "" 100 | [1]=> 101 | string(14) " |1| 2a |2| 2a" 102 | } 103 | 104 | --> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 105 | 106 | Deprecated: Function split() is deprecated in %s on line %d 107 | array(1) { 108 | [0]=> 109 | string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 110 | } 111 | 112 | --> Pattern: '^[[:digit:]]{5}'; match: '0123456789' 113 | 114 | Deprecated: Function split() is deprecated in %s on line %d 115 | array(2) { 116 | [0]=> 117 | string(0) "" 118 | [1]=> 119 | string(35) "56789 |1| 0123456789 |2| 0123456789" 120 | } 121 | 122 | --> Pattern: '[[:digit:]]{5}$'; match: '0123456789' 123 | 124 | Deprecated: Function split() is deprecated in %s on line %d 125 | array(2) { 126 | [0]=> 127 | string(35) "0123456789 |1| 0123456789 |2| 01234" 128 | [1]=> 129 | string(0) "" 130 | } 131 | 132 | --> Pattern: '[[:blank:]]{1,10}'; match: ' 133 | ' 134 | 135 | Deprecated: Function split() is deprecated in %s on line %d 136 | array(2) { 137 | [0]=> 138 | string(1) " 139 | " 140 | [1]=> 141 | string(15) "|1| 142 | |2| 143 | " 144 | } 145 | 146 | --> Pattern: '[[:print:]]{3}'; match: ' a ' 147 | 148 | Deprecated: Function split() is deprecated in %s on line %d 149 | array(2) { 150 | [0]=> 151 | string(0) "" 152 | [1]=> 153 | string(16) " |1| a |2| a " 154 | } 155 | Done 156 | -------------------------------------------------------------------------------- /tests/spliti_basic_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : basic functionality - test a number of simple spliti, specifying a limit 3 | --FILE-- 4 | Pattern: '$pattern'; match: '$string'\n"; 22 | var_dump(spliti($pattern, $string . ' |1| ' . $string . ' |2| ' . $string, 2)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing ereg() : basic functionality *** 29 | 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---' 31 | 32 | Deprecated: Function spliti() is deprecated in %s on line %d 33 | array(2) { 34 | [0]=> 35 | string(2) "--" 36 | [1]=> 37 | string(32) "-- |1| --- ab --- |2| --- ab ---" 38 | } 39 | 40 | --> Pattern: '()'; match: '' 41 | 42 | Deprecated: Function spliti() is deprecated in %s on line %d 43 | 44 | Warning: spliti(): Invalid Regular Expression in %s on line %d 45 | bool(false) 46 | 47 | --> Pattern: '()'; match: 'abcdef' 48 | 49 | Deprecated: Function spliti() is deprecated in %s on line %d 50 | 51 | Warning: spliti(): Invalid Regular Expression in %s on line %d 52 | bool(false) 53 | 54 | --> Pattern: '[x]|[^x]'; match: 'abcdef' 55 | 56 | Deprecated: Function spliti() is deprecated in %s on line %d 57 | array(2) { 58 | [0]=> 59 | string(0) "" 60 | [1]=> 61 | string(27) "bcdef |1| abcdef |2| abcdef" 62 | } 63 | 64 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---' 65 | 66 | Deprecated: Function spliti() is deprecated in %s on line %d 67 | array(2) { 68 | [0]=> 69 | string(4) "--- " 70 | [1]=> 71 | string(60) " --- |1| --- aaa bbb ccc ddd --- |2| --- aaa bbb ccc ddd ---" 72 | } 73 | 74 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{'' 75 | 76 | Deprecated: Function spliti() is deprecated in %s on line %d 77 | array(2) { 78 | [0]=> 79 | string(0) "" 80 | [1]=> 81 | string(38) " |1| \`^.[$()|*+?{' |2| \`^.[$()|*+?{'" 82 | } 83 | 84 | --> Pattern: '\a'; match: 'a' 85 | 86 | Deprecated: Function spliti() is deprecated in %s on line %d 87 | array(2) { 88 | [0]=> 89 | string(0) "" 90 | [1]=> 91 | string(12) " |1| a |2| a" 92 | } 93 | 94 | --> Pattern: '[0-9][^0-9]'; match: '2a' 95 | 96 | Deprecated: Function spliti() is deprecated in %s on line %d 97 | array(2) { 98 | [0]=> 99 | string(0) "" 100 | [1]=> 101 | string(14) " |1| 2a |2| 2a" 102 | } 103 | 104 | --> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 105 | 106 | Deprecated: Function spliti() is deprecated in %s on line %d 107 | array(1) { 108 | [0]=> 109 | string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 110 | } 111 | 112 | --> Pattern: '^[[:digit:]]{5}'; match: '0123456789' 113 | 114 | Deprecated: Function spliti() is deprecated in %s on line %d 115 | array(2) { 116 | [0]=> 117 | string(0) "" 118 | [1]=> 119 | string(35) "56789 |1| 0123456789 |2| 0123456789" 120 | } 121 | 122 | --> Pattern: '[[:digit:]]{5}$'; match: '0123456789' 123 | 124 | Deprecated: Function spliti() is deprecated in %s on line %d 125 | array(2) { 126 | [0]=> 127 | string(35) "0123456789 |1| 0123456789 |2| 01234" 128 | [1]=> 129 | string(0) "" 130 | } 131 | 132 | --> Pattern: '[[:blank:]]{1,10}'; match: ' 133 | ' 134 | 135 | Deprecated: Function spliti() is deprecated in %s on line %d 136 | array(2) { 137 | [0]=> 138 | string(1) " 139 | " 140 | [1]=> 141 | string(15) "|1| 142 | |2| 143 | " 144 | } 145 | 146 | --> Pattern: '[[:print:]]{3}'; match: ' a ' 147 | 148 | Deprecated: Function spliti() is deprecated in %s on line %d 149 | array(2) { 150 | [0]=> 151 | string(0) "" 152 | [1]=> 153 | string(16) " |1| a |2| a " 154 | } 155 | Done 156 | -------------------------------------------------------------------------------- /regex/regexec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * the outer shell of regexec() 3 | * 4 | * This file includes engine.c *twice*, after muchos fiddling with the 5 | * macros that code uses. This lets the same code operate on two different 6 | * representations for state sets. 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "regex.h" 16 | #include "utils.h" 17 | #include "regex2.h" 18 | 19 | #define PHP_REGEX_NOPE 0; /* for use in asserts; shuts lint up */ 20 | 21 | /* macros for manipulating states, small version */ 22 | #define states unsigned 23 | #define states1 unsigned /* for later use in regexec() decision */ 24 | #define CLEAR(v) ((v) = 0) 25 | #define SET0(v, n) ((v) &= ~((unsigned)1 << (n))) 26 | #define SET1(v, n) ((v) |= (unsigned)1 << (n)) 27 | #define ISSET(v, n) ((v) & ((unsigned)1 << (n))) 28 | #define ASSIGN(d, s) ((d) = (s)) 29 | #define EQ(a, b) ((a) == (b)) 30 | #define STATEVARS int dummy /* dummy version */ 31 | #define STATESETUP(m, n) /* nothing */ 32 | #define STATETEARDOWN(m) /* nothing */ 33 | #define SETUP(v) ((v) = 0) 34 | #define onestate unsigned 35 | #define INIT(o, n) ((o) = (unsigned)1 << (n)) 36 | #define INC(o) ((o) <<= 1) 37 | #define ISSTATEIN(v, o) ((v) & (o)) 38 | /* some abbreviations; note that some of these know variable names! */ 39 | /* do "if I'm here, I can also be there" etc without branches */ 40 | #define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n)) 41 | #define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n)) 42 | #define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n))) 43 | /* function names */ 44 | #define SNAMES /* engine.c looks after details */ 45 | 46 | #include "engine.c" 47 | 48 | /* now undo things */ 49 | #undef states 50 | #undef CLEAR 51 | #undef SET0 52 | #undef SET1 53 | #undef ISSET 54 | #undef ASSIGN 55 | #undef EQ 56 | #undef STATEVARS 57 | #undef STATESETUP 58 | #undef STATETEARDOWN 59 | #undef SETUP 60 | #undef onestate 61 | #undef INIT 62 | #undef INC 63 | #undef ISSTATEIN 64 | #undef FWD 65 | #undef BACK 66 | #undef ISSETBACK 67 | #undef SNAMES 68 | 69 | /* macros for manipulating states, large version */ 70 | #define states unsigned char * 71 | #define CLEAR(v) memset(v, 0, m->g->nstates) 72 | #define SET0(v, n) ((v)[n] = 0) 73 | #define SET1(v, n) ((v)[n] = 1) 74 | #define ISSET(v, n) ((v)[n]) 75 | #define ASSIGN(d, s) memcpy(d, s, m->g->nstates) 76 | #define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) 77 | #define STATEVARS int vn; unsigned char *space 78 | #define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ 79 | if ((m)->space == NULL) return(REG_ESPACE); \ 80 | (m)->vn = 0; } 81 | #define STATETEARDOWN(m) { free((m)->space); } 82 | #define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) 83 | #define onestate int 84 | #define INIT(o, n) ((o) = (n)) 85 | #define INC(o) ((o)++) 86 | #define ISSTATEIN(v, o) ((v)[o]) 87 | /* some abbreviations; note that some of these know variable names! */ 88 | /* do "if I'm here, I can also be there" etc without branches */ 89 | #define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here]) 90 | #define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here]) 91 | #define ISSETBACK(v, n) ((v)[here - (n)]) 92 | /* function names */ 93 | #define LNAMES /* flag */ 94 | 95 | #include "engine.c" 96 | 97 | /* 98 | - regexec - interface for matching 99 | = API_EXPORT(int) regexec(const regex_t *, const char *, size_t, \ 100 | = regmatch_t [], int); 101 | = #define REG_NOTBOL 00001 102 | = #define REG_NOTEOL 00002 103 | = #define REG_STARTEND 00004 104 | = #define REG_TRACE 00400 // tracing of execution 105 | = #define REG_LARGE 01000 // force large representation 106 | = #define REG_BACKR 02000 // force use of backref code 107 | * 108 | * We put this here so we can exploit knowledge of the state representation 109 | * when choosing which matcher to call. Also, by this point the matchers 110 | * have been prototyped. 111 | */ 112 | API_EXPORT(int) /* 0 success, REG_NOMATCH failure */ 113 | regexec(preg, string, nmatch, pmatch, eflags) 114 | const regex_t *preg; 115 | const char *string; 116 | size_t nmatch; 117 | regmatch_t pmatch[]; 118 | int eflags; 119 | { 120 | register struct re_guts *g = preg->re_g; 121 | #ifdef REDEBUG 122 | # define GOODFLAGS(f) (f) 123 | #else 124 | # define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND)) 125 | #endif 126 | 127 | if (preg->re_magic != MAGIC1 || g->magic != MAGIC2) 128 | return(REG_BADPAT); 129 | assert(!(g->iflags&BAD)); 130 | if (g->iflags&BAD) /* backstop for no-debug case */ 131 | return(REG_BADPAT); 132 | eflags = GOODFLAGS(eflags); 133 | 134 | if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) 135 | return(smatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); 136 | else 137 | return(lmatcher(g, (unsigned char *)string, nmatch, pmatch, eflags)); 138 | } 139 | -------------------------------------------------------------------------------- /tests/ereg_variation_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : usage variations - unexpected type arg 2 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for string 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( ereg($pattern, $value, $registers) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing ereg() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function ereg() is deprecated, %s(74) 89 | bool(false) 90 | 91 | Arg value 1 92 | Error: 8192 - Function ereg() is deprecated, %s(74) 93 | int(1) 94 | 95 | Arg value 12345 96 | Error: 8192 - Function ereg() is deprecated, %s(74) 97 | int(1) 98 | 99 | Arg value -2345 100 | Error: 8192 - Function ereg() is deprecated, %s(74) 101 | bool(false) 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function ereg() is deprecated, %s(74) 105 | int(1) 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function ereg() is deprecated, %s(74) 109 | int(1) 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function ereg() is deprecated, %s(74) 113 | int(1) 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function ereg() is deprecated, %s(74) 117 | int(1) 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function ereg() is deprecated, %s(74) 121 | bool(false) 122 | Error: 8 - Array to string conversion, %sereg_variation_002.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function ereg() is deprecated, %s(74) 126 | Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74) 127 | NULL 128 | Error: 8 - Array to string conversion, %sereg_variation_002.php(%d) 129 | 130 | Arg value Array 131 | Error: 8192 - Function ereg() is deprecated, %s(74) 132 | Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74) 133 | NULL 134 | Error: 8 - Array to string conversion, %sereg_variation_002.php(%d) 135 | 136 | Arg value Array 137 | Error: 8192 - Function ereg() is deprecated, %s(74) 138 | Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74) 139 | NULL 140 | Error: 8 - Array to string conversion, %sereg_variation_002.php(%d) 141 | 142 | Arg value Array 143 | Error: 8192 - Function ereg() is deprecated, %s(74) 144 | Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74) 145 | NULL 146 | Error: 8 - Array to string conversion, %sereg_variation_002.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function ereg() is deprecated, %s(74) 150 | Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74) 151 | NULL 152 | 153 | Arg value 154 | Error: 8192 - Function ereg() is deprecated, %s(74) 155 | bool(false) 156 | 157 | Arg value 158 | Error: 8192 - Function ereg() is deprecated, %s(74) 159 | bool(false) 160 | 161 | Arg value 1 162 | Error: 8192 - Function ereg() is deprecated, %s(74) 163 | int(1) 164 | 165 | Arg value 166 | Error: 8192 - Function ereg() is deprecated, %s(74) 167 | bool(false) 168 | 169 | Arg value 1 170 | Error: 8192 - Function ereg() is deprecated, %s(74) 171 | int(1) 172 | 173 | Arg value 174 | Error: 8192 - Function ereg() is deprecated, %s(74) 175 | bool(false) 176 | 177 | Arg value 178 | Error: 8192 - Function ereg() is deprecated, %s(74) 179 | bool(false) 180 | 181 | Arg value 182 | Error: 8192 - Function ereg() is deprecated, %s(74) 183 | bool(false) 184 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 185 | 186 | Arg value 187 | Error: 8192 - Function ereg() is deprecated, %s(74) 188 | Error: 2 - ereg() expects parameter 2 to be string, object given, %s(74) 189 | NULL 190 | 191 | Arg value 192 | Error: 8192 - Function ereg() is deprecated, %s(74) 193 | bool(false) 194 | 195 | Arg value 196 | Error: 8192 - Function ereg() is deprecated, %s(74) 197 | bool(false) 198 | Done 199 | -------------------------------------------------------------------------------- /tests/eregi_variation_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : usage variations - unexpected type arg 2 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for string 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( eregi($pattern, $value, $registers) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing eregi() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function eregi() is deprecated, %s(74) 89 | bool(false) 90 | 91 | Arg value 1 92 | Error: 8192 - Function eregi() is deprecated, %s(74) 93 | int(1) 94 | 95 | Arg value 12345 96 | Error: 8192 - Function eregi() is deprecated, %s(74) 97 | int(1) 98 | 99 | Arg value -2345 100 | Error: 8192 - Function eregi() is deprecated, %s(74) 101 | bool(false) 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function eregi() is deprecated, %s(74) 105 | int(1) 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function eregi() is deprecated, %s(74) 109 | int(1) 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function eregi() is deprecated, %s(74) 113 | int(1) 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function eregi() is deprecated, %s(74) 117 | int(1) 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function eregi() is deprecated, %s(74) 121 | bool(false) 122 | Error: 8 - Array to string conversion, %seregi_variation_002.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function eregi() is deprecated, %s(74) 126 | Error: 2 - eregi() expects parameter 2 to be string, array given, %s(74) 127 | NULL 128 | Error: 8 - Array to string conversion, %seregi_variation_002.php(%d) 129 | 130 | Arg value Array 131 | Error: 8192 - Function eregi() is deprecated, %s(74) 132 | Error: 2 - eregi() expects parameter 2 to be string, array given, %s(74) 133 | NULL 134 | Error: 8 - Array to string conversion, %seregi_variation_002.php(%d) 135 | 136 | Arg value Array 137 | Error: 8192 - Function eregi() is deprecated, %s(74) 138 | Error: 2 - eregi() expects parameter 2 to be string, array given, %s(74) 139 | NULL 140 | Error: 8 - Array to string conversion, %seregi_variation_002.php(%d) 141 | 142 | Arg value Array 143 | Error: 8192 - Function eregi() is deprecated, %s(74) 144 | Error: 2 - eregi() expects parameter 2 to be string, array given, %s(74) 145 | NULL 146 | Error: 8 - Array to string conversion, %seregi_variation_002.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function eregi() is deprecated, %s(74) 150 | Error: 2 - eregi() expects parameter 2 to be string, array given, %s(74) 151 | NULL 152 | 153 | Arg value 154 | Error: 8192 - Function eregi() is deprecated, %s(74) 155 | bool(false) 156 | 157 | Arg value 158 | Error: 8192 - Function eregi() is deprecated, %s(74) 159 | bool(false) 160 | 161 | Arg value 1 162 | Error: 8192 - Function eregi() is deprecated, %s(74) 163 | int(1) 164 | 165 | Arg value 166 | Error: 8192 - Function eregi() is deprecated, %s(74) 167 | bool(false) 168 | 169 | Arg value 1 170 | Error: 8192 - Function eregi() is deprecated, %s(74) 171 | int(1) 172 | 173 | Arg value 174 | Error: 8192 - Function eregi() is deprecated, %s(74) 175 | bool(false) 176 | 177 | Arg value 178 | Error: 8192 - Function eregi() is deprecated, %s(74) 179 | bool(false) 180 | 181 | Arg value 182 | Error: 8192 - Function eregi() is deprecated, %s(74) 183 | bool(false) 184 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 185 | 186 | Arg value 187 | Error: 8192 - Function eregi() is deprecated, %s(74) 188 | Error: 2 - eregi() expects parameter 2 to be string, object given, %s(74) 189 | NULL 190 | 191 | Arg value 192 | Error: 8192 - Function eregi() is deprecated, %s(74) 193 | bool(false) 194 | 195 | Arg value 196 | Error: 8192 - Function eregi() is deprecated, %s(74) 197 | bool(false) 198 | Done 199 | -------------------------------------------------------------------------------- /regex/WHATSNEW: -------------------------------------------------------------------------------- 1 | New in alpha3.4: The complex bug alluded to below has been fixed (in a 2 | slightly kludgey temporary way that may hurt efficiency a bit; this is 3 | another "get it out the door for 4.4" release). The tests at the end of 4 | the tests file have accordingly been uncommented. The primary sign of 5 | the bug was that something like a?b matching ab matched b rather than ab. 6 | (The bug was essentially specific to this exact situation, else it would 7 | have shown up earlier.) 8 | 9 | New in alpha3.3: The definition of word boundaries has been altered 10 | slightly, to more closely match the usual programming notion that "_" 11 | is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir, 12 | and the makefile no longer alludes to it in mysterious ways. The 13 | makefile has generally been cleaned up some. Fixes have been made 14 | (again!) so that the regression test will run without -DREDEBUG, at 15 | the cost of weaker checking. A workaround for a bug in some folks' 16 | has been added. And some more things have been added to 17 | tests, including a couple right at the end which are commented out 18 | because the code currently flunks them (complex bug; fix coming). 19 | Plus the usual minor cleanup. 20 | 21 | New in alpha3.2: Assorted bits of cleanup and portability improvement 22 | (the development base is now a BSDI system using GCC instead of an ancient 23 | Sun system, and the newer compiler exposed some glitches). Fix for a 24 | serious bug that affected REs using many [] (including REG_ICASE REs 25 | because of the way they are implemented), *sometimes*, depending on 26 | memory-allocation patterns. The header-file prototypes no longer name 27 | the parameters, avoiding possible name conflicts. The possibility that 28 | some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is 29 | now handled gracefully. "uchar" is no longer used as an internal type 30 | name (too many people have the same idea). Still the same old lousy 31 | performance, alas. 32 | 33 | New in alpha3.1: Basically nothing, this release is just a bookkeeping 34 | convenience. Stay tuned. 35 | 36 | New in alpha3.0: Performance is no better, alas, but some fixes have been 37 | made and some functionality has been added. (This is basically the "get 38 | it out the door in time for 4.4" release.) One bug fix: regfree() didn't 39 | free the main internal structure (how embarrassing). It is now possible 40 | to put NULs in either the RE or the target string, using (resp.) a new 41 | REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to 42 | regcomp() makes all characters ordinary, so you can match a literal 43 | string easily (this will become more useful when performance improves!). 44 | There are now primitives to match beginnings and ends of words, although 45 | the syntax is disgusting and so is the implementation. The REG_ATOI 46 | debugging interface has changed a bit. And there has been considerable 47 | internal cleanup of various kinds. 48 | 49 | New in alpha2.3: Split change list out of README, and moved flags notes 50 | into Makefile. Macro-ized the name of regex(7) in regex(3), since it has 51 | to change for 4.4BSD. Cleanup work in engine.c, and some new regression 52 | tests to catch tricky cases thereof. 53 | 54 | New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two 55 | small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges 56 | in my own test program and might be useful to others for similar purposes. 57 | The regression test will now compile (and run) without REDEBUG. The 58 | BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now. 59 | Char/uchar parameters are now written int/unsigned, to avoid possible 60 | portability problems with unpromoted parameters. Some unsigned casts have 61 | been introduced to minimize portability problems with shifting into sign 62 | bits. 63 | 64 | New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big 65 | thing is that regex.h is now generated, using mkh, rather than being 66 | supplied in the distribution; due to circularities in dependencies, 67 | you have to build regex.h explicitly by "make h". The two known bugs 68 | have been fixed (and the regression test now checks for them), as has a 69 | problem with assertions not being suppressed in the absence of REDEBUG. 70 | No performance work yet. 71 | 72 | New in alpha2: Backslash-anything is an ordinary character, not an 73 | error (except, of course, for the handful of backslashed metacharacters 74 | in BREs), which should reduce script breakage. The regression test 75 | checks *where* null strings are supposed to match, and has generally 76 | been tightened up somewhat. Small bug fixes in parameter passing (not 77 | harmful, but technically errors) and some other areas. Debugging 78 | invoked by defining REDEBUG rather than not defining NDEBUG. 79 | 80 | New in alpha+3: full prototyping for internal routines, using a little 81 | helper program, mkh, which extracts prototypes given in stylized comments. 82 | More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple 83 | pre-screening of input when a literal string is known to be part of the 84 | RE; this does wonders for performance. 85 | 86 | New in alpha+2: minor bits of cleanup. Notably, the number "32" for the 87 | word width isn't hardwired into regexec.c any more, the public header 88 | file prototypes the functions if __STDC__ is defined, and some small typos 89 | in the manpages have been fixed. 90 | 91 | New in alpha+1: improvements to the manual pages, and an important 92 | extension, the REG_STARTEND option to regexec(). 93 | -------------------------------------------------------------------------------- /tests/ereg_replace_variation_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : usage variations - unexpected type arg 2 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for replacement 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump(urlencode(ereg_replace($pattern, $value, $string))); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing ereg_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 89 | string(5) "ho%21" 90 | 91 | Arg value 1 92 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 93 | string(8) "h%01o%21" 94 | 95 | Arg value 12345 96 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 97 | string(6) "h9o%21" 98 | 99 | Arg value -2345 100 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 101 | string(8) "h%D7o%21" 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 105 | string(8) "h%0Ao%21" 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 109 | string(8) "h%F6o%21" 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 113 | string(%d) "h%so%21" 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 117 | string(5) "ho%21" 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 121 | string(5) "ho%21" 122 | Error: 8 - Array to string conversion, %sereg_replace_variation_002.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 126 | string(5) "ho%21" 127 | Error: 8 - Array to string conversion, %sereg_replace_variation_002.php(%d) 128 | 129 | Arg value Array 130 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 131 | string(8) "h%01o%21" 132 | Error: 8 - Array to string conversion, %sereg_replace_variation_002.php(%d) 133 | 134 | Arg value Array 135 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 136 | string(8) "h%01o%21" 137 | Error: 8 - Array to string conversion, %sereg_replace_variation_002.php(%d) 138 | 139 | Arg value Array 140 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 141 | string(8) "h%01o%21" 142 | Error: 8 - Array to string conversion, %sereg_replace_variation_002.php(%d) 143 | 144 | Arg value Array 145 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 146 | string(8) "h%01o%21" 147 | 148 | Arg value 149 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 150 | string(5) "ho%21" 151 | 152 | Arg value 153 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 154 | string(5) "ho%21" 155 | 156 | Arg value 1 157 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 158 | string(8) "h%01o%21" 159 | 160 | Arg value 161 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 162 | string(5) "ho%21" 163 | 164 | Arg value 1 165 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 166 | string(8) "h%01o%21" 167 | 168 | Arg value 169 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 170 | string(5) "ho%21" 171 | 172 | Arg value 173 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 174 | string(5) "ho%21" 175 | 176 | Arg value 177 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 178 | string(5) "ho%21" 179 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 180 | 181 | Arg value 182 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 183 | Error: 8 - Object of class stdClass could not be converted to int, %s(74) 184 | string(8) "h%01o%21" 185 | 186 | Arg value 187 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 188 | string(5) "ho%21" 189 | 190 | Arg value 191 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 192 | string(5) "ho%21" 193 | Done -------------------------------------------------------------------------------- /tests/eregi_replace_variation_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : usage variations - unexpected type arg 2 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for replacement 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump(urlencode(eregi_replace($pattern, $value, $string))); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing eregi_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 89 | string(5) "ho%21" 90 | 91 | Arg value 1 92 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 93 | string(8) "h%01o%21" 94 | 95 | Arg value 12345 96 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 97 | string(6) "h9o%21" 98 | 99 | Arg value -2345 100 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 101 | string(8) "h%D7o%21" 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 105 | string(8) "h%0Ao%21" 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 109 | string(8) "h%F6o%21" 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 113 | string(%d) "h%so%21" 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 117 | string(5) "ho%21" 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 121 | string(5) "ho%21" 122 | Error: 8 - Array to string conversion, %seregi_replace_variation_002.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 126 | string(5) "ho%21" 127 | Error: 8 - Array to string conversion, %seregi_replace_variation_002.php(%d) 128 | 129 | Arg value Array 130 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 131 | string(8) "h%01o%21" 132 | Error: 8 - Array to string conversion, %seregi_replace_variation_002.php(%d) 133 | 134 | Arg value Array 135 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 136 | string(8) "h%01o%21" 137 | Error: 8 - Array to string conversion, %seregi_replace_variation_002.php(%d) 138 | 139 | Arg value Array 140 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 141 | string(8) "h%01o%21" 142 | Error: 8 - Array to string conversion, %seregi_replace_variation_002.php(%d) 143 | 144 | Arg value Array 145 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 146 | string(8) "h%01o%21" 147 | 148 | Arg value 149 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 150 | string(5) "ho%21" 151 | 152 | Arg value 153 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 154 | string(5) "ho%21" 155 | 156 | Arg value 1 157 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 158 | string(8) "h%01o%21" 159 | 160 | Arg value 161 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 162 | string(5) "ho%21" 163 | 164 | Arg value 1 165 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 166 | string(8) "h%01o%21" 167 | 168 | Arg value 169 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 170 | string(5) "ho%21" 171 | 172 | Arg value 173 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 174 | string(5) "ho%21" 175 | 176 | Arg value 177 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 178 | string(5) "ho%21" 179 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 180 | 181 | Arg value 182 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 183 | Error: 8 - Object of class stdClass could not be converted to int, %s(74) 184 | string(8) "h%01o%21" 185 | 186 | Arg value 187 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 188 | string(5) "ho%21" 189 | 190 | Arg value 191 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 192 | string(5) "ho%21" 193 | Done -------------------------------------------------------------------------------- /tests/sql_regcase_variation_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test sql_regcase() function : usage variations - unexpected arg type 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 46 | 47 | // null data 48 | NULL, 49 | null, 50 | 51 | // boolean data 52 | true, 53 | false, 54 | TRUE, 55 | FALSE, 56 | 57 | // empty data 58 | "", 59 | '', 60 | 61 | // object data 62 | new stdclass(), 63 | 64 | // undefined data 65 | $undefined_var, 66 | 67 | // unset data 68 | $unset_var, 69 | ); 70 | 71 | // loop through each element of the array for string 72 | 73 | foreach($values as $value) { 74 | echo "\nArg value $value \n"; 75 | var_dump( sql_regcase($value) ); 76 | }; 77 | 78 | echo "Done"; 79 | ?> 80 | --EXPECTF-- 81 | *** Testing sql_regcase() : usage variations *** 82 | Error: 8 - Undefined variable: undefined_var, %s(62) 83 | Error: 8 - Undefined variable: unset_var, %s(65) 84 | 85 | Arg value 0 86 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 87 | string(1) "0" 88 | 89 | Arg value 1 90 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 91 | string(1) "1" 92 | 93 | Arg value 12345 94 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 95 | string(5) "12345" 96 | 97 | Arg value -2345 98 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 99 | string(5) "-2345" 100 | 101 | Arg value 10.5 102 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 103 | string(4) "10.5" 104 | 105 | Arg value -10.5 106 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 107 | string(5) "-10.5" 108 | 109 | Arg value 101234567000 110 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 111 | string(12) "101234567000" 112 | 113 | Arg value 1.07654321E-9 114 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 115 | string(16) "1.07654321[Ee]-9" 116 | 117 | Arg value 0.5 118 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 119 | string(3) "0.5" 120 | Error: 8 - Array to string conversion, %ssql_regcase_variation_001.php(%d) 121 | 122 | Arg value Array 123 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 124 | Error: 2 - sql_regcase() expects parameter 1 to be string, array given, %s(72) 125 | NULL 126 | Error: 8 - Array to string conversion, %ssql_regcase_variation_001.php(%d) 127 | 128 | Arg value Array 129 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 130 | Error: 2 - sql_regcase() expects parameter 1 to be string, array given, %s(72) 131 | NULL 132 | Error: 8 - Array to string conversion, %ssql_regcase_variation_001.php(%d) 133 | 134 | Arg value Array 135 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 136 | Error: 2 - sql_regcase() expects parameter 1 to be string, array given, %s(72) 137 | NULL 138 | Error: 8 - Array to string conversion, %ssql_regcase_variation_001.php(%d) 139 | 140 | Arg value Array 141 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 142 | Error: 2 - sql_regcase() expects parameter 1 to be string, array given, %s(72) 143 | NULL 144 | Error: 8 - Array to string conversion, %ssql_regcase_variation_001.php(%d) 145 | 146 | Arg value Array 147 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 148 | Error: 2 - sql_regcase() expects parameter 1 to be string, array given, %s(72) 149 | NULL 150 | 151 | Arg value 152 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 153 | string(0) "" 154 | 155 | Arg value 156 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 157 | string(0) "" 158 | 159 | Arg value 1 160 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 161 | string(1) "1" 162 | 163 | Arg value 164 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 165 | string(0) "" 166 | 167 | Arg value 1 168 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 169 | string(1) "1" 170 | 171 | Arg value 172 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 173 | string(0) "" 174 | 175 | Arg value 176 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 177 | string(0) "" 178 | 179 | Arg value 180 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 181 | string(0) "" 182 | Error: 4096 - Object of class stdClass could not be converted to string, %s(71) 183 | 184 | Arg value 185 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 186 | Error: 2 - sql_regcase() expects parameter 1 to be string, object given, %s(72) 187 | NULL 188 | 189 | Arg value 190 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 191 | string(0) "" 192 | 193 | Arg value 194 | Error: 8192 - Function sql_regcase() is deprecated, %s(72) 195 | string(0) "" 196 | Done 197 | -------------------------------------------------------------------------------- /tests/ereg_variation_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg() function : usage variations - unexpected type arg 1 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 49 | 50 | // null data 51 | NULL, 52 | null, 53 | 54 | // boolean data 55 | true, 56 | false, 57 | TRUE, 58 | FALSE, 59 | 60 | // empty data 61 | "", 62 | '', 63 | 64 | // object data 65 | new stdclass(), 66 | 67 | // undefined data 68 | $undefined_var, 69 | 70 | // unset data 71 | $unset_var, 72 | ); 73 | 74 | // loop through each element of the array for pattern 75 | 76 | foreach($values as $value) { 77 | echo "\nArg value $value \n"; 78 | var_dump( ereg($value, $string, $registers) ); 79 | }; 80 | 81 | echo "Done"; 82 | ?> 83 | --EXPECTF-- 84 | *** Testing ereg() : usage variations *** 85 | Error: 8 - Undefined variable: undefined_var, %s(65) 86 | Error: 8 - Undefined variable: unset_var, %s(68) 87 | 88 | Arg value 0 89 | Error: 8192 - Function ereg() is deprecated, %s(75) 90 | bool(false) 91 | 92 | Arg value 1 93 | Error: 8192 - Function ereg() is deprecated, %s(75) 94 | int(1) 95 | 96 | Arg value 12345 97 | Error: 8192 - Function ereg() is deprecated, %s(75) 98 | bool(false) 99 | 100 | Arg value -2345 101 | Error: 8192 - Function ereg() is deprecated, %s(75) 102 | bool(false) 103 | 104 | Arg value 10.5 105 | Error: 8192 - Function ereg() is deprecated, %s(75) 106 | bool(false) 107 | 108 | Arg value -10.5 109 | Error: 8192 - Function ereg() is deprecated, %s(75) 110 | bool(false) 111 | 112 | Arg value 101234567000 113 | Error: 8192 - Function ereg() is deprecated, %s(75) 114 | bool(false) 115 | 116 | Arg value 1.07654321E-9 117 | Error: 8192 - Function ereg() is deprecated, %s(75) 118 | bool(false) 119 | 120 | Arg value 0.5 121 | Error: 8192 - Function ereg() is deprecated, %s(75) 122 | bool(false) 123 | Error: 8 - Array to string conversion, %sereg_variation_001.php(%d) 124 | 125 | Arg value Array 126 | Error: 8192 - Function ereg() is deprecated, %s(75) 127 | Error: 8 - Array to string conversion, %s(75) 128 | bool(false) 129 | Error: 8 - Array to string conversion, %sereg_variation_001.php(%d) 130 | 131 | Arg value Array 132 | Error: 8192 - Function ereg() is deprecated, %s(75) 133 | Error: 8 - Array to string conversion, %s(75) 134 | bool(false) 135 | Error: 8 - Array to string conversion, %sereg_variation_001.php(%d) 136 | 137 | Arg value Array 138 | Error: 8192 - Function ereg() is deprecated, %s(75) 139 | Error: 8 - Array to string conversion, %s(75) 140 | bool(false) 141 | Error: 8 - Array to string conversion, %sereg_variation_001.php(%d) 142 | 143 | Arg value Array 144 | Error: 8192 - Function ereg() is deprecated, %s(75) 145 | Error: 8 - Array to string conversion, %s(75) 146 | bool(false) 147 | Error: 8 - Array to string conversion, %sereg_variation_001.php(%d) 148 | 149 | Arg value Array 150 | Error: 8192 - Function ereg() is deprecated, %s(75) 151 | Error: 8 - Array to string conversion, %s(75) 152 | bool(false) 153 | 154 | Arg value 155 | Error: 8192 - Function ereg() is deprecated, %s(75) 156 | Error: 2 - ereg(): REG_EMPTY, %s(75) 157 | bool(false) 158 | 159 | Arg value 160 | Error: 8192 - Function ereg() is deprecated, %s(75) 161 | Error: 2 - ereg(): REG_EMPTY, %s(75) 162 | bool(false) 163 | 164 | Arg value 1 165 | Error: 8192 - Function ereg() is deprecated, %s(75) 166 | int(1) 167 | 168 | Arg value 169 | Error: 8192 - Function ereg() is deprecated, %s(75) 170 | Error: 2 - ereg(): REG_EMPTY, %s(75) 171 | bool(false) 172 | 173 | Arg value 1 174 | Error: 8192 - Function ereg() is deprecated, %s(75) 175 | int(1) 176 | 177 | Arg value 178 | Error: 8192 - Function ereg() is deprecated, %s(75) 179 | Error: 2 - ereg(): REG_EMPTY, %s(75) 180 | bool(false) 181 | 182 | Arg value 183 | Error: 8192 - Function ereg() is deprecated, %s(75) 184 | Error: 2 - ereg(): REG_EMPTY, %s(75) 185 | bool(false) 186 | 187 | Arg value 188 | Error: 8192 - Function ereg() is deprecated, %s(75) 189 | Error: 2 - ereg(): REG_EMPTY, %s(75) 190 | bool(false) 191 | Error: 4096 - Object of class stdClass could not be converted to string, %s(74) 192 | 193 | Arg value 194 | Error: 8192 - Function ereg() is deprecated, %s(75) 195 | Error: 4096 - Object of class stdClass could not be converted to string, %s(75) 196 | Error: 8 - Object of class stdClass to string conversion, %s(75) 197 | bool(false) 198 | 199 | Arg value 200 | Error: 8192 - Function ereg() is deprecated, %s(75) 201 | Error: 2 - ereg(): REG_EMPTY, %s(75) 202 | bool(false) 203 | 204 | Arg value 205 | Error: 8192 - Function ereg() is deprecated, %s(75) 206 | Error: 2 - ereg(): REG_EMPTY, %s(75) 207 | bool(false) 208 | Done 209 | -------------------------------------------------------------------------------- /tests/eregi_variation_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi() function : usage variations - unexpected type arg 1 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 49 | 50 | // null data 51 | NULL, 52 | null, 53 | 54 | // boolean data 55 | true, 56 | false, 57 | TRUE, 58 | FALSE, 59 | 60 | // empty data 61 | "", 62 | '', 63 | 64 | // object data 65 | new stdclass(), 66 | 67 | // undefined data 68 | $undefined_var, 69 | 70 | // unset data 71 | $unset_var, 72 | ); 73 | 74 | // loop through each element of the array for pattern 75 | 76 | foreach($values as $value) { 77 | echo "\nArg value $value \n"; 78 | var_dump( eregi($value, $string, $registers) ); 79 | }; 80 | 81 | echo "Done"; 82 | ?> 83 | --EXPECTF-- 84 | *** Testing eregi() : usage variations *** 85 | Error: 8 - Undefined variable: undefined_var, %s(65) 86 | Error: 8 - Undefined variable: unset_var, %s(68) 87 | 88 | Arg value 0 89 | Error: 8192 - Function eregi() is deprecated, %s(75) 90 | bool(false) 91 | 92 | Arg value 1 93 | Error: 8192 - Function eregi() is deprecated, %s(75) 94 | int(1) 95 | 96 | Arg value 12345 97 | Error: 8192 - Function eregi() is deprecated, %s(75) 98 | bool(false) 99 | 100 | Arg value -2345 101 | Error: 8192 - Function eregi() is deprecated, %s(75) 102 | bool(false) 103 | 104 | Arg value 10.5 105 | Error: 8192 - Function eregi() is deprecated, %s(75) 106 | bool(false) 107 | 108 | Arg value -10.5 109 | Error: 8192 - Function eregi() is deprecated, %s(75) 110 | bool(false) 111 | 112 | Arg value 101234567000 113 | Error: 8192 - Function eregi() is deprecated, %s(75) 114 | bool(false) 115 | 116 | Arg value 1.07654321E-9 117 | Error: 8192 - Function eregi() is deprecated, %s(75) 118 | bool(false) 119 | 120 | Arg value 0.5 121 | Error: 8192 - Function eregi() is deprecated, %s(75) 122 | bool(false) 123 | Error: 8 - Array to string conversion, %seregi_variation_001.php(%d) 124 | 125 | Arg value Array 126 | Error: 8192 - Function eregi() is deprecated, %s(75) 127 | Error: 8 - Array to string conversion, %s(75) 128 | bool(false) 129 | Error: 8 - Array to string conversion, %seregi_variation_001.php(%d) 130 | 131 | Arg value Array 132 | Error: 8192 - Function eregi() is deprecated, %s(75) 133 | Error: 8 - Array to string conversion, %s(75) 134 | bool(false) 135 | Error: 8 - Array to string conversion, %seregi_variation_001.php(%d) 136 | 137 | Arg value Array 138 | Error: 8192 - Function eregi() is deprecated, %s(75) 139 | Error: 8 - Array to string conversion, %s(75) 140 | bool(false) 141 | Error: 8 - Array to string conversion, %seregi_variation_001.php(%d) 142 | 143 | Arg value Array 144 | Error: 8192 - Function eregi() is deprecated, %s(75) 145 | Error: 8 - Array to string conversion, %s(75) 146 | bool(false) 147 | Error: 8 - Array to string conversion, %seregi_variation_001.php(%d) 148 | 149 | Arg value Array 150 | Error: 8192 - Function eregi() is deprecated, %s(75) 151 | Error: 8 - Array to string conversion, %s(75) 152 | bool(false) 153 | 154 | Arg value 155 | Error: 8192 - Function eregi() is deprecated, %s(75) 156 | Error: 2 - eregi(): REG_EMPTY, %s(75) 157 | bool(false) 158 | 159 | Arg value 160 | Error: 8192 - Function eregi() is deprecated, %s(75) 161 | Error: 2 - eregi(): REG_EMPTY, %s(75) 162 | bool(false) 163 | 164 | Arg value 1 165 | Error: 8192 - Function eregi() is deprecated, %s(75) 166 | int(1) 167 | 168 | Arg value 169 | Error: 8192 - Function eregi() is deprecated, %s(75) 170 | Error: 2 - eregi(): REG_EMPTY, %s(75) 171 | bool(false) 172 | 173 | Arg value 1 174 | Error: 8192 - Function eregi() is deprecated, %s(75) 175 | int(1) 176 | 177 | Arg value 178 | Error: 8192 - Function eregi() is deprecated, %s(75) 179 | Error: 2 - eregi(): REG_EMPTY, %s(75) 180 | bool(false) 181 | 182 | Arg value 183 | Error: 8192 - Function eregi() is deprecated, %s(75) 184 | Error: 2 - eregi(): REG_EMPTY, %s(75) 185 | bool(false) 186 | 187 | Arg value 188 | Error: 8192 - Function eregi() is deprecated, %s(75) 189 | Error: 2 - eregi(): REG_EMPTY, %s(75) 190 | bool(false) 191 | Error: 4096 - Object of class stdClass could not be converted to string, %s(74) 192 | 193 | Arg value 194 | Error: 8192 - Function eregi() is deprecated, %s(75) 195 | Error: 4096 - Object of class stdClass could not be converted to string, %s(75) 196 | Error: 8 - Object of class stdClass to string conversion, %s(75) 197 | bool(false) 198 | 199 | Arg value 200 | Error: 8192 - Function eregi() is deprecated, %s(75) 201 | Error: 2 - eregi(): REG_EMPTY, %s(75) 202 | bool(false) 203 | 204 | Arg value 205 | Error: 8192 - Function eregi() is deprecated, %s(75) 206 | Error: 2 - eregi(): REG_EMPTY, %s(75) 207 | bool(false) 208 | Done 209 | -------------------------------------------------------------------------------- /tests/split_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : basic functionality - test a number of simple split, without specifying a limit 3 | --FILE-- 4 | Pattern: '$pattern'; match: '$string'\n"; 22 | var_dump(split($pattern, $string . ' |1| ' . $string . ' |2| ' . $string)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing ereg() : basic functionality *** 29 | 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---' 31 | 32 | Deprecated: Function split() is deprecated in %s on line %d 33 | array(4) { 34 | [0]=> 35 | string(2) "--" 36 | [1]=> 37 | string(9) "-- |1| --" 38 | [2]=> 39 | string(9) "-- |2| --" 40 | [3]=> 41 | string(2) "--" 42 | } 43 | 44 | --> Pattern: '()'; match: '' 45 | 46 | Deprecated: Function split() is deprecated in %s on line %d 47 | 48 | Warning: split(): Invalid Regular Expression in %s on line %d 49 | bool(false) 50 | 51 | --> Pattern: '()'; match: 'abcdef' 52 | 53 | Deprecated: Function split() is deprecated in %s on line %d 54 | 55 | Warning: split(): Invalid Regular Expression in %s on line %d 56 | bool(false) 57 | 58 | --> Pattern: '[x]|[^x]'; match: 'abcdef' 59 | 60 | Deprecated: Function split() is deprecated in %s on line %d 61 | array(29) { 62 | [0]=> 63 | string(0) "" 64 | [1]=> 65 | string(0) "" 66 | [2]=> 67 | string(0) "" 68 | [3]=> 69 | string(0) "" 70 | [4]=> 71 | string(0) "" 72 | [5]=> 73 | string(0) "" 74 | [6]=> 75 | string(0) "" 76 | [7]=> 77 | string(0) "" 78 | [8]=> 79 | string(0) "" 80 | [9]=> 81 | string(0) "" 82 | [10]=> 83 | string(0) "" 84 | [11]=> 85 | string(0) "" 86 | [12]=> 87 | string(0) "" 88 | [13]=> 89 | string(0) "" 90 | [14]=> 91 | string(0) "" 92 | [15]=> 93 | string(0) "" 94 | [16]=> 95 | string(0) "" 96 | [17]=> 97 | string(0) "" 98 | [18]=> 99 | string(0) "" 100 | [19]=> 101 | string(0) "" 102 | [20]=> 103 | string(0) "" 104 | [21]=> 105 | string(0) "" 106 | [22]=> 107 | string(0) "" 108 | [23]=> 109 | string(0) "" 110 | [24]=> 111 | string(0) "" 112 | [25]=> 113 | string(0) "" 114 | [26]=> 115 | string(0) "" 116 | [27]=> 117 | string(0) "" 118 | [28]=> 119 | string(0) "" 120 | } 121 | 122 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---' 123 | 124 | Deprecated: Function split() is deprecated in %s on line %d 125 | array(4) { 126 | [0]=> 127 | string(4) "--- " 128 | [1]=> 129 | string(13) " --- |1| --- " 130 | [2]=> 131 | string(13) " --- |2| --- " 132 | [3]=> 133 | string(4) " ---" 134 | } 135 | 136 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{'' 137 | 138 | Deprecated: Function split() is deprecated in %s on line %d 139 | array(4) { 140 | [0]=> 141 | string(0) "" 142 | [1]=> 143 | string(5) " |1| " 144 | [2]=> 145 | string(5) " |2| " 146 | [3]=> 147 | string(0) "" 148 | } 149 | 150 | --> Pattern: '\a'; match: 'a' 151 | 152 | Deprecated: Function split() is deprecated in %s on line %d 153 | array(4) { 154 | [0]=> 155 | string(0) "" 156 | [1]=> 157 | string(5) " |1| " 158 | [2]=> 159 | string(5) " |2| " 160 | [3]=> 161 | string(0) "" 162 | } 163 | 164 | --> Pattern: '[0-9][^0-9]'; match: '2a' 165 | 166 | Deprecated: Function split() is deprecated in %s on line %d 167 | array(6) { 168 | [0]=> 169 | string(0) "" 170 | [1]=> 171 | string(2) " |" 172 | [2]=> 173 | string(1) " " 174 | [3]=> 175 | string(2) " |" 176 | [4]=> 177 | string(1) " " 178 | [5]=> 179 | string(0) "" 180 | } 181 | 182 | --> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 183 | 184 | Deprecated: Function split() is deprecated in %s on line %d 185 | array(1) { 186 | [0]=> 187 | string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 188 | } 189 | 190 | --> Pattern: '^[[:digit:]]{5}'; match: '0123456789' 191 | 192 | Deprecated: Function split() is deprecated in %s on line %d 193 | array(3) { 194 | [0]=> 195 | string(0) "" 196 | [1]=> 197 | string(0) "" 198 | [2]=> 199 | string(30) " |1| 0123456789 |2| 0123456789" 200 | } 201 | 202 | --> Pattern: '[[:digit:]]{5}$'; match: '0123456789' 203 | 204 | Deprecated: Function split() is deprecated in %s on line %d 205 | array(2) { 206 | [0]=> 207 | string(35) "0123456789 |1| 0123456789 |2| 01234" 208 | [1]=> 209 | string(0) "" 210 | } 211 | 212 | --> Pattern: '[[:blank:]]{1,10}'; match: ' 213 | ' 214 | 215 | Deprecated: Function split() is deprecated in %s on line %d 216 | array(6) { 217 | [0]=> 218 | string(1) " 219 | " 220 | [1]=> 221 | string(3) "|1|" 222 | [2]=> 223 | string(1) " 224 | " 225 | [3]=> 226 | string(3) "|2|" 227 | [4]=> 228 | string(1) " 229 | " 230 | [5]=> 231 | string(0) "" 232 | } 233 | 234 | --> Pattern: '[[:print:]]{3}'; match: ' a ' 235 | 236 | Deprecated: Function split() is deprecated in %s on line %d 237 | array(7) { 238 | [0]=> 239 | string(0) "" 240 | [1]=> 241 | string(0) "" 242 | [2]=> 243 | string(0) "" 244 | [3]=> 245 | string(0) "" 246 | [4]=> 247 | string(0) "" 248 | [5]=> 249 | string(0) "" 250 | [6]=> 251 | string(1) " " 252 | } 253 | Done 254 | -------------------------------------------------------------------------------- /tests/spliti_basic_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : basic functionality - test a number of simple spliti, without specifying a limit 3 | --FILE-- 4 | Pattern: '$pattern'; match: '$string'\n"; 22 | var_dump(spliti($pattern, $string . ' |1| ' . $string . ' |2| ' . $string)); 23 | } 24 | 25 | echo "Done"; 26 | ?> 27 | --EXPECTF-- 28 | *** Testing ereg() : basic functionality *** 29 | 30 | --> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---' 31 | 32 | Deprecated: Function spliti() is deprecated in %s on line %d 33 | array(4) { 34 | [0]=> 35 | string(2) "--" 36 | [1]=> 37 | string(9) "-- |1| --" 38 | [2]=> 39 | string(9) "-- |2| --" 40 | [3]=> 41 | string(2) "--" 42 | } 43 | 44 | --> Pattern: '()'; match: '' 45 | 46 | Deprecated: Function spliti() is deprecated in %s on line %d 47 | 48 | Warning: spliti(): Invalid Regular Expression in %s on line %d 49 | bool(false) 50 | 51 | --> Pattern: '()'; match: 'abcdef' 52 | 53 | Deprecated: Function spliti() is deprecated in %s on line %d 54 | 55 | Warning: spliti(): Invalid Regular Expression in %s on line %d 56 | bool(false) 57 | 58 | --> Pattern: '[x]|[^x]'; match: 'abcdef' 59 | 60 | Deprecated: Function spliti() is deprecated in %s on line %d 61 | array(29) { 62 | [0]=> 63 | string(0) "" 64 | [1]=> 65 | string(0) "" 66 | [2]=> 67 | string(0) "" 68 | [3]=> 69 | string(0) "" 70 | [4]=> 71 | string(0) "" 72 | [5]=> 73 | string(0) "" 74 | [6]=> 75 | string(0) "" 76 | [7]=> 77 | string(0) "" 78 | [8]=> 79 | string(0) "" 80 | [9]=> 81 | string(0) "" 82 | [10]=> 83 | string(0) "" 84 | [11]=> 85 | string(0) "" 86 | [12]=> 87 | string(0) "" 88 | [13]=> 89 | string(0) "" 90 | [14]=> 91 | string(0) "" 92 | [15]=> 93 | string(0) "" 94 | [16]=> 95 | string(0) "" 96 | [17]=> 97 | string(0) "" 98 | [18]=> 99 | string(0) "" 100 | [19]=> 101 | string(0) "" 102 | [20]=> 103 | string(0) "" 104 | [21]=> 105 | string(0) "" 106 | [22]=> 107 | string(0) "" 108 | [23]=> 109 | string(0) "" 110 | [24]=> 111 | string(0) "" 112 | [25]=> 113 | string(0) "" 114 | [26]=> 115 | string(0) "" 116 | [27]=> 117 | string(0) "" 118 | [28]=> 119 | string(0) "" 120 | } 121 | 122 | --> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---' 123 | 124 | Deprecated: Function spliti() is deprecated in %s on line %d 125 | array(4) { 126 | [0]=> 127 | string(4) "--- " 128 | [1]=> 129 | string(13) " --- |1| --- " 130 | [2]=> 131 | string(13) " --- |2| --- " 132 | [3]=> 133 | string(4) " ---" 134 | } 135 | 136 | --> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{'' 137 | 138 | Deprecated: Function spliti() is deprecated in %s on line %d 139 | array(4) { 140 | [0]=> 141 | string(0) "" 142 | [1]=> 143 | string(5) " |1| " 144 | [2]=> 145 | string(5) " |2| " 146 | [3]=> 147 | string(0) "" 148 | } 149 | 150 | --> Pattern: '\a'; match: 'a' 151 | 152 | Deprecated: Function spliti() is deprecated in %s on line %d 153 | array(4) { 154 | [0]=> 155 | string(0) "" 156 | [1]=> 157 | string(5) " |1| " 158 | [2]=> 159 | string(5) " |2| " 160 | [3]=> 161 | string(0) "" 162 | } 163 | 164 | --> Pattern: '[0-9][^0-9]'; match: '2a' 165 | 166 | Deprecated: Function spliti() is deprecated in %s on line %d 167 | array(6) { 168 | [0]=> 169 | string(0) "" 170 | [1]=> 171 | string(2) " |" 172 | [2]=> 173 | string(1) " " 174 | [3]=> 175 | string(2) " |" 176 | [4]=> 177 | string(1) " " 178 | [5]=> 179 | string(0) "" 180 | } 181 | 182 | --> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 183 | 184 | Deprecated: Function spliti() is deprecated in %s on line %d 185 | array(1) { 186 | [0]=> 187 | string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 188 | } 189 | 190 | --> Pattern: '^[[:digit:]]{5}'; match: '0123456789' 191 | 192 | Deprecated: Function spliti() is deprecated in %s on line %d 193 | array(3) { 194 | [0]=> 195 | string(0) "" 196 | [1]=> 197 | string(0) "" 198 | [2]=> 199 | string(30) " |1| 0123456789 |2| 0123456789" 200 | } 201 | 202 | --> Pattern: '[[:digit:]]{5}$'; match: '0123456789' 203 | 204 | Deprecated: Function spliti() is deprecated in %s on line %d 205 | array(2) { 206 | [0]=> 207 | string(35) "0123456789 |1| 0123456789 |2| 01234" 208 | [1]=> 209 | string(0) "" 210 | } 211 | 212 | --> Pattern: '[[:blank:]]{1,10}'; match: ' 213 | ' 214 | 215 | Deprecated: Function spliti() is deprecated in %s on line %d 216 | array(6) { 217 | [0]=> 218 | string(1) " 219 | " 220 | [1]=> 221 | string(3) "|1|" 222 | [2]=> 223 | string(1) " 224 | " 225 | [3]=> 226 | string(3) "|2|" 227 | [4]=> 228 | string(1) " 229 | " 230 | [5]=> 231 | string(0) "" 232 | } 233 | 234 | --> Pattern: '[[:print:]]{3}'; match: ' a ' 235 | 236 | Deprecated: Function spliti() is deprecated in %s on line %d 237 | array(7) { 238 | [0]=> 239 | string(0) "" 240 | [1]=> 241 | string(0) "" 242 | [2]=> 243 | string(0) "" 244 | [3]=> 245 | string(0) "" 246 | [4]=> 247 | string(0) "" 248 | [5]=> 249 | string(0) "" 250 | [6]=> 251 | string(1) " " 252 | } 253 | Done 254 | -------------------------------------------------------------------------------- /tests/ereg_replace_variation_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : usage variations - unexpected type arg 3 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for string 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( ereg_replace($pattern, $replacement, $value) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing ereg_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 89 | string(1) "0" 90 | 91 | Arg value 1 92 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 93 | string(9) "new value" 94 | 95 | Arg value 12345 96 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 97 | string(13) "new value2345" 98 | 99 | Arg value -2345 100 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 101 | string(5) "-2345" 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 105 | string(12) "new value0.5" 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 109 | string(13) "-new value0.5" 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 113 | string(28) "new value0new value234567000" 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 117 | string(29) "new value.0765432new valueE-9" 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 121 | string(3) "0.5" 122 | Error: 8 - Array to string conversion, %sereg_replace_variation_003.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 126 | Error: 2 - ereg_replace() expects parameter 3 to be string, array given, %s(74) 127 | NULL 128 | Error: 8 - Array to string conversion, %sereg_replace_variation_003.php(%d) 129 | 130 | Arg value Array 131 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 132 | Error: 2 - ereg_replace() expects parameter 3 to be string, array given, %s(74) 133 | NULL 134 | Error: 8 - Array to string conversion, %sereg_replace_variation_003.php(%d) 135 | 136 | Arg value Array 137 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 138 | Error: 2 - ereg_replace() expects parameter 3 to be string, array given, %s(74) 139 | NULL 140 | Error: 8 - Array to string conversion, %sereg_replace_variation_003.php(%d) 141 | 142 | Arg value Array 143 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 144 | Error: 2 - ereg_replace() expects parameter 3 to be string, array given, %s(74) 145 | NULL 146 | Error: 8 - Array to string conversion, %sereg_replace_variation_003.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 150 | Error: 2 - ereg_replace() expects parameter 3 to be string, array given, %s(74) 151 | NULL 152 | 153 | Arg value 154 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 155 | string(0) "" 156 | 157 | Arg value 158 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 159 | string(0) "" 160 | 161 | Arg value 1 162 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 163 | string(9) "new value" 164 | 165 | Arg value 166 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 167 | string(0) "" 168 | 169 | Arg value 1 170 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 171 | string(9) "new value" 172 | 173 | Arg value 174 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 175 | string(0) "" 176 | 177 | Arg value 178 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 179 | string(0) "" 180 | 181 | Arg value 182 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 183 | string(0) "" 184 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 185 | 186 | Arg value 187 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 188 | Error: 2 - ereg_replace() expects parameter 3 to be string, object given, %s(74) 189 | NULL 190 | 191 | Arg value 192 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 193 | string(0) "" 194 | 195 | Arg value 196 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 197 | string(0) "" 198 | Done 199 | -------------------------------------------------------------------------------- /tests/eregi_replace_variation_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : usage variations - unexpected type arg 3 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for string 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( eregi_replace($pattern, $replacement, $value) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing eregi_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 89 | string(1) "0" 90 | 91 | Arg value 1 92 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 93 | string(9) "new value" 94 | 95 | Arg value 12345 96 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 97 | string(13) "new value2345" 98 | 99 | Arg value -2345 100 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 101 | string(5) "-2345" 102 | 103 | Arg value 10.5 104 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 105 | string(12) "new value0.5" 106 | 107 | Arg value -10.5 108 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 109 | string(13) "-new value0.5" 110 | 111 | Arg value 101234567000 112 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 113 | string(28) "new value0new value234567000" 114 | 115 | Arg value 1.07654321E-9 116 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 117 | string(29) "new value.0765432new valueE-9" 118 | 119 | Arg value 0.5 120 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 121 | string(3) "0.5" 122 | Error: 8 - Array to string conversion, %seregi_replace_variation_003.php(%d) 123 | 124 | Arg value Array 125 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 126 | Error: 2 - eregi_replace() expects parameter 3 to be string, array given, %s(74) 127 | NULL 128 | Error: 8 - Array to string conversion, %seregi_replace_variation_003.php(%d) 129 | 130 | Arg value Array 131 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 132 | Error: 2 - eregi_replace() expects parameter 3 to be string, array given, %s(74) 133 | NULL 134 | Error: 8 - Array to string conversion, %seregi_replace_variation_003.php(%d) 135 | 136 | Arg value Array 137 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 138 | Error: 2 - eregi_replace() expects parameter 3 to be string, array given, %s(74) 139 | NULL 140 | Error: 8 - Array to string conversion, %seregi_replace_variation_003.php(%d) 141 | 142 | Arg value Array 143 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 144 | Error: 2 - eregi_replace() expects parameter 3 to be string, array given, %s(74) 145 | NULL 146 | Error: 8 - Array to string conversion, %seregi_replace_variation_003.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 150 | Error: 2 - eregi_replace() expects parameter 3 to be string, array given, %s(74) 151 | NULL 152 | 153 | Arg value 154 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 155 | string(0) "" 156 | 157 | Arg value 158 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 159 | string(0) "" 160 | 161 | Arg value 1 162 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 163 | string(9) "new value" 164 | 165 | Arg value 166 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 167 | string(0) "" 168 | 169 | Arg value 1 170 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 171 | string(9) "new value" 172 | 173 | Arg value 174 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 175 | string(0) "" 176 | 177 | Arg value 178 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 179 | string(0) "" 180 | 181 | Arg value 182 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 183 | string(0) "" 184 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 185 | 186 | Arg value 187 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 188 | Error: 2 - eregi_replace() expects parameter 3 to be string, object given, %s(74) 189 | NULL 190 | 191 | Arg value 192 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 193 | string(0) "" 194 | 195 | Arg value 196 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 197 | string(0) "" 198 | Done 199 | -------------------------------------------------------------------------------- /tests/ereg_replace_variation_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ereg_replace() function : usage variations - unexpected type arg 1 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for pattern 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( ereg_replace($value, $replacement, $string) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing ereg_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 89 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 90 | bool(false) 91 | 92 | Arg value 1 93 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 94 | string(8) "original" 95 | 96 | Arg value 12345 97 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 98 | string(8) "original" 99 | 100 | Arg value -2345 101 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 102 | string(8) "original" 103 | 104 | Arg value 10.5 105 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 106 | string(8) "original" 107 | 108 | Arg value -10.5 109 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 110 | string(8) "original" 111 | 112 | Arg value 101234567000 113 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 114 | string(8) "original" 115 | 116 | Arg value 1.07654321E-9 117 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 118 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 119 | bool(false) 120 | 121 | Arg value 0.5 122 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 123 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 124 | bool(false) 125 | Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d) 126 | 127 | Arg value Array 128 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 129 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 130 | bool(false) 131 | Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d) 132 | 133 | Arg value Array 134 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 135 | string(8) "original" 136 | Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d) 137 | 138 | Arg value Array 139 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 140 | string(8) "original" 141 | Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d) 142 | 143 | Arg value Array 144 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 145 | string(8) "original" 146 | Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 150 | string(8) "original" 151 | 152 | Arg value 153 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 154 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 155 | bool(false) 156 | 157 | Arg value 158 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 159 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 160 | bool(false) 161 | 162 | Arg value 1 163 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 164 | string(8) "original" 165 | 166 | Arg value 167 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 168 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 169 | bool(false) 170 | 171 | Arg value 1 172 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 173 | string(8) "original" 174 | 175 | Arg value 176 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 177 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 178 | bool(false) 179 | 180 | Arg value 181 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 182 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 183 | bool(false) 184 | 185 | Arg value 186 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 187 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 188 | bool(false) 189 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 190 | 191 | Arg value 192 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 193 | Error: 8 - Object of class stdClass could not be converted to int, %s(74) 194 | string(8) "original" 195 | 196 | Arg value 197 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 198 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 199 | bool(false) 200 | 201 | Arg value 202 | Error: 8192 - Function ereg_replace() is deprecated, %s(74) 203 | Error: 2 - ereg_replace(): REG_EMPTY, %s(74) 204 | bool(false) 205 | Done 206 | -------------------------------------------------------------------------------- /regex/regex2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * First, the stuff that ends up in the outside-world include file 3 | = #ifdef WIN32 4 | = #define API_EXPORT(type) __declspec(dllexport) type __stdcall 5 | = #else 6 | = #define API_EXPORT(type) type 7 | = #endif 8 | = 9 | = typedef off_t regoff_t; 10 | = typedef struct { 11 | = int re_magic; 12 | = size_t re_nsub; // number of parenthesized subexpressions 13 | = const unsigned char *re_endp; // end pointer for REG_PEND 14 | = struct re_guts *re_g; // none of your business :-) 15 | = } regex_t; 16 | = typedef struct { 17 | = regoff_t rm_so; // start of match 18 | = regoff_t rm_eo; // end of match 19 | = } regmatch_t; 20 | */ 21 | /* 22 | * internals of regex_t 23 | */ 24 | #define MAGIC1 ((('r'^0200)<<8) | 'e') 25 | 26 | /* 27 | * The internal representation is a *strip*, a sequence of 28 | * operators ending with an endmarker. (Some terminology etc. is a 29 | * historical relic of earlier versions which used multiple strips.) 30 | * Certain oddities in the representation are there to permit running 31 | * the machinery backwards; in particular, any deviation from sequential 32 | * flow must be marked at both its source and its destination. Some 33 | * fine points: 34 | * 35 | * - OPLUS_ and O_PLUS are *inside* the loop they create. 36 | * - OQUEST_ and O_QUEST are *outside* the bypass they create. 37 | * - OCH_ and O_CH are *outside* the multi-way branch they create, while 38 | * OOR1 and OOR2 are respectively the end and the beginning of one of 39 | * the branches. Note that there is an implicit OOR2 following OCH_ 40 | * and an implicit OOR1 preceding O_CH. 41 | * 42 | * In state representations, an operator's bit is on to signify a state 43 | * immediately *preceding* "execution" of that operator. 44 | */ 45 | typedef long sop; /* strip operator */ 46 | typedef long sopno; 47 | #define OPRMASK 0x7c000000 48 | #define OPDMASK 0x03ffffff 49 | #define OPSHIFT (26) 50 | #define OP(n) ((n)&OPRMASK) 51 | #define OPND(n) ((n)&OPDMASK) 52 | #define SOP(op, opnd) ((op)|(opnd)) 53 | /* operators meaning operand */ 54 | /* (back, fwd are offsets) */ 55 | #define OEND (1< uch [csetsize] */ 90 | uch mask; /* bit within array */ 91 | uch hash; /* hash code */ 92 | size_t smultis; 93 | unsigned char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ 94 | } cset; 95 | /* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ 96 | #define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) 97 | #define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) 98 | #define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) 99 | #define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */ 100 | #define MCsub(p, cs, cp) mcsub(p, cs, cp) 101 | #define MCin(p, cs, cp) mcin(p, cs, cp) 102 | 103 | /* stuff for character categories */ 104 | typedef unsigned char cat_t; 105 | 106 | /* 107 | * main compiled-expression structure 108 | */ 109 | struct re_guts { 110 | int magic; 111 | # define MAGIC2 ((('R'^0200)<<8)|'E') 112 | sop *strip; /* malloced area for strip */ 113 | int csetsize; /* number of bits in a cset vector */ 114 | int ncsets; /* number of csets in use */ 115 | cset *sets; /* -> cset [ncsets] */ 116 | uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ 117 | int cflags; /* copy of regcomp() cflags argument */ 118 | sopno nstates; /* = number of sops */ 119 | sopno firststate; /* the initial OEND (normally 0) */ 120 | sopno laststate; /* the final OEND */ 121 | int iflags; /* internal flags */ 122 | # define USEBOL 01 /* used ^ */ 123 | # define USEEOL 02 /* used $ */ 124 | # define BAD 04 /* something wrong */ 125 | int nbol; /* number of ^ used */ 126 | int neol; /* number of $ used */ 127 | int ncategories; /* how many character categories */ 128 | cat_t *categories; /* ->catspace[-UCHAR_MIN] */ 129 | unsigned char *must; /* match must contain this string */ 130 | int mlen; /* length of must */ 131 | size_t nsub; /* copy of re_nsub */ 132 | int backrefs; /* does it use back references? */ 133 | sopno nplus; /* how deep does it nest +s? */ 134 | /* catspace must be last */ 135 | cat_t catspace[1]; /* actually [NC] */ 136 | }; 137 | 138 | /* misc utilities */ 139 | #define OUT (UCHAR_MAX+1) /* a non-character value */ 140 | #define ISWORD(c) (isalnum(c) || (c) == '_') 141 | -------------------------------------------------------------------------------- /tests/split_variation_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test split() function : usage variations - unexpected type for arg 3 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 43 | 44 | // null data 45 | NULL, 46 | null, 47 | 48 | // boolean data 49 | true, 50 | false, 51 | TRUE, 52 | FALSE, 53 | 54 | // empty data 55 | "", 56 | '', 57 | 58 | // string data 59 | "string", 60 | 'string', 61 | 62 | // object data 63 | new stdclass(), 64 | 65 | // undefined data 66 | @$undefined_var, 67 | 68 | // unset data 69 | @$unset_var, 70 | ); 71 | 72 | // loop through each element of the array for limit 73 | 74 | foreach($values as $value) { 75 | echo "\nArg value $value \n"; 76 | var_dump( split($pattern, $string, $value) ); 77 | }; 78 | 79 | echo "Done"; 80 | ?> 81 | --EXPECTF-- 82 | *** Testing split() : usage variations *** 83 | 84 | Arg value 10.5 85 | Error: 8192 - Function split() is deprecated, %s(73) 86 | array(5) { 87 | [0]=> 88 | string(1) "1" 89 | [1]=> 90 | string(1) "2" 91 | [2]=> 92 | string(1) "3" 93 | [3]=> 94 | string(1) "4" 95 | [4]=> 96 | string(1) "5" 97 | } 98 | 99 | Arg value -10.5 100 | Error: 8192 - Function split() is deprecated, %s(73) 101 | array(1) { 102 | [0]=> 103 | string(9) "1 2 3 4 5" 104 | } 105 | 106 | Arg value 1.07654321E-9 107 | Error: 8192 - Function split() is deprecated, %s(73) 108 | array(1) { 109 | [0]=> 110 | string(9) "1 2 3 4 5" 111 | } 112 | 113 | Arg value 0.5 114 | Error: 8192 - Function split() is deprecated, %s(73) 115 | array(1) { 116 | [0]=> 117 | string(9) "1 2 3 4 5" 118 | } 119 | Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d) 120 | 121 | Arg value Array 122 | Error: 8192 - Function split() is deprecated, %s(73) 123 | Error: 2 - split() expects parameter 3 to be integer, array given, %s(73) 124 | NULL 125 | Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d) 126 | 127 | Arg value Array 128 | Error: 8192 - Function split() is deprecated, %s(73) 129 | Error: 2 - split() expects parameter 3 to be integer, array given, %s(73) 130 | NULL 131 | Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d) 132 | 133 | Arg value Array 134 | Error: 8192 - Function split() is deprecated, %s(73) 135 | Error: 2 - split() expects parameter 3 to be integer, array given, %s(73) 136 | NULL 137 | Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d) 138 | 139 | Arg value Array 140 | Error: 8192 - Function split() is deprecated, %s(73) 141 | Error: 2 - split() expects parameter 3 to be integer, array given, %s(73) 142 | NULL 143 | Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d) 144 | 145 | Arg value Array 146 | Error: 8192 - Function split() is deprecated, %s(73) 147 | Error: 2 - split() expects parameter 3 to be integer, array given, %s(73) 148 | NULL 149 | 150 | Arg value 151 | Error: 8192 - Function split() is deprecated, %s(73) 152 | array(1) { 153 | [0]=> 154 | string(9) "1 2 3 4 5" 155 | } 156 | 157 | Arg value 158 | Error: 8192 - Function split() is deprecated, %s(73) 159 | array(1) { 160 | [0]=> 161 | string(9) "1 2 3 4 5" 162 | } 163 | 164 | Arg value 1 165 | Error: 8192 - Function split() is deprecated, %s(73) 166 | array(1) { 167 | [0]=> 168 | string(9) "1 2 3 4 5" 169 | } 170 | 171 | Arg value 172 | Error: 8192 - Function split() is deprecated, %s(73) 173 | array(1) { 174 | [0]=> 175 | string(9) "1 2 3 4 5" 176 | } 177 | 178 | Arg value 1 179 | Error: 8192 - Function split() is deprecated, %s(73) 180 | array(1) { 181 | [0]=> 182 | string(9) "1 2 3 4 5" 183 | } 184 | 185 | Arg value 186 | Error: 8192 - Function split() is deprecated, %s(73) 187 | array(1) { 188 | [0]=> 189 | string(9) "1 2 3 4 5" 190 | } 191 | 192 | Arg value 193 | Error: 8192 - Function split() is deprecated, %s(73) 194 | Error: 2 - split() expects parameter 3 to be integer, string given, %s(73) 195 | NULL 196 | 197 | Arg value 198 | Error: 8192 - Function split() is deprecated, %s(73) 199 | Error: 2 - split() expects parameter 3 to be integer, string given, %s(73) 200 | NULL 201 | 202 | Arg value string 203 | Error: 8192 - Function split() is deprecated, %s(73) 204 | Error: 2 - split() expects parameter 3 to be integer, string given, %s(73) 205 | NULL 206 | 207 | Arg value string 208 | Error: 8192 - Function split() is deprecated, %s(73) 209 | Error: 2 - split() expects parameter 3 to be integer, string given, %s(73) 210 | NULL 211 | Error: 4096 - Object of class stdClass could not be converted to string, %s(72) 212 | 213 | Arg value 214 | Error: 8192 - Function split() is deprecated, %s(73) 215 | Error: 2 - split() expects parameter 3 to be integer, object given, %s(73) 216 | NULL 217 | 218 | Arg value 219 | Error: 8192 - Function split() is deprecated, %s(73) 220 | array(1) { 221 | [0]=> 222 | string(9) "1 2 3 4 5" 223 | } 224 | 225 | Arg value 226 | Error: 8192 - Function split() is deprecated, %s(73) 227 | array(1) { 228 | [0]=> 229 | string(9) "1 2 3 4 5" 230 | } 231 | Done -------------------------------------------------------------------------------- /tests/eregi_replace_variation_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test eregi_replace() function : usage variations - unexpected type arg 1 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 48 | 49 | // null data 50 | NULL, 51 | null, 52 | 53 | // boolean data 54 | true, 55 | false, 56 | TRUE, 57 | FALSE, 58 | 59 | // empty data 60 | "", 61 | '', 62 | 63 | // object data 64 | new stdclass(), 65 | 66 | // undefined data 67 | $undefined_var, 68 | 69 | // unset data 70 | $unset_var, 71 | ); 72 | 73 | // loop through each element of the array for pattern 74 | 75 | foreach($values as $value) { 76 | echo "\nArg value $value \n"; 77 | var_dump( eregi_replace($value, $replacement, $string) ); 78 | }; 79 | 80 | echo "Done"; 81 | ?> 82 | --EXPECTF-- 83 | *** Testing eregi_replace() : usage variations *** 84 | Error: 8 - Undefined variable: undefined_var, %s(64) 85 | Error: 8 - Undefined variable: unset_var, %s(67) 86 | 87 | Arg value 0 88 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 89 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 90 | bool(false) 91 | 92 | Arg value 1 93 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 94 | string(8) "original" 95 | 96 | Arg value 12345 97 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 98 | string(8) "original" 99 | 100 | Arg value -2345 101 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 102 | string(8) "original" 103 | 104 | Arg value 10.5 105 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 106 | string(8) "original" 107 | 108 | Arg value -10.5 109 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 110 | string(8) "original" 111 | 112 | Arg value 101234567000 113 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 114 | string(8) "original" 115 | 116 | Arg value 1.07654321E-9 117 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 118 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 119 | bool(false) 120 | 121 | Arg value 0.5 122 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 123 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 124 | bool(false) 125 | Error: 8 - Array to string conversion, %seregi_replace_variation_001.php(%d) 126 | 127 | Arg value Array 128 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 129 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 130 | bool(false) 131 | Error: 8 - Array to string conversion, %seregi_replace_variation_001.php(%d) 132 | 133 | Arg value Array 134 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 135 | string(8) "original" 136 | Error: 8 - Array to string conversion, %seregi_replace_variation_001.php(%d) 137 | 138 | Arg value Array 139 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 140 | string(8) "original" 141 | Error: 8 - Array to string conversion, %seregi_replace_variation_001.php(%d) 142 | 143 | Arg value Array 144 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 145 | string(8) "original" 146 | Error: 8 - Array to string conversion, %seregi_replace_variation_001.php(%d) 147 | 148 | Arg value Array 149 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 150 | string(8) "original" 151 | 152 | Arg value 153 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 154 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 155 | bool(false) 156 | 157 | Arg value 158 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 159 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 160 | bool(false) 161 | 162 | Arg value 1 163 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 164 | string(8) "original" 165 | 166 | Arg value 167 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 168 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 169 | bool(false) 170 | 171 | Arg value 1 172 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 173 | string(8) "original" 174 | 175 | Arg value 176 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 177 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 178 | bool(false) 179 | 180 | Arg value 181 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 182 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 183 | bool(false) 184 | 185 | Arg value 186 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 187 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 188 | bool(false) 189 | Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 190 | 191 | Arg value 192 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 193 | Error: 8 - Object of class stdClass could not be converted to int, %s(74) 194 | string(8) "original" 195 | 196 | Arg value 197 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 198 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 199 | bool(false) 200 | 201 | Arg value 202 | Error: 8192 - Function eregi_replace() is deprecated, %s(74) 203 | Error: 2 - eregi_replace(): REG_EMPTY, %s(74) 204 | bool(false) 205 | Done 206 | -------------------------------------------------------------------------------- /tests/spliti_variation_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test spliti() function : usage variations - unexpected type for arg 3 3 | --FILE-- 4 | 'red', 'item' => 'pen'), 43 | 44 | // null data 45 | NULL, 46 | null, 47 | 48 | // boolean data 49 | true, 50 | false, 51 | TRUE, 52 | FALSE, 53 | 54 | // empty data 55 | "", 56 | '', 57 | 58 | // string data 59 | "string", 60 | 'string', 61 | 62 | // object data 63 | new stdclass(), 64 | 65 | // undefined data 66 | @$undefined_var, 67 | 68 | // unset data 69 | @$unset_var, 70 | ); 71 | 72 | // loop through each element of the array for limit 73 | 74 | foreach($values as $value) { 75 | echo "\nArg value $value \n"; 76 | var_dump( spliti($pattern, $string, $value) ); 77 | }; 78 | 79 | echo "Done"; 80 | ?> 81 | --EXPECTF-- 82 | *** Testing spliti() : usage variations *** 83 | 84 | Arg value 10.5 85 | Error: 8192 - Function spliti() is deprecated, %s(73) 86 | array(5) { 87 | [0]=> 88 | string(1) "1" 89 | [1]=> 90 | string(1) "2" 91 | [2]=> 92 | string(1) "3" 93 | [3]=> 94 | string(1) "4" 95 | [4]=> 96 | string(1) "5" 97 | } 98 | 99 | Arg value -10.5 100 | Error: 8192 - Function spliti() is deprecated, %s(73) 101 | array(1) { 102 | [0]=> 103 | string(9) "1 2 3 4 5" 104 | } 105 | 106 | Arg value 1.07654321E-9 107 | Error: 8192 - Function spliti() is deprecated, %s(73) 108 | array(1) { 109 | [0]=> 110 | string(9) "1 2 3 4 5" 111 | } 112 | 113 | Arg value 0.5 114 | Error: 8192 - Function spliti() is deprecated, %s(73) 115 | array(1) { 116 | [0]=> 117 | string(9) "1 2 3 4 5" 118 | } 119 | Error: 8 - Array to string conversion, %sspliti_variation_003.php(%d) 120 | 121 | Arg value Array 122 | Error: 8192 - Function spliti() is deprecated, %s(73) 123 | Error: 2 - spliti() expects parameter 3 to be integer, array given, %s(73) 124 | NULL 125 | Error: 8 - Array to string conversion, %sspliti_variation_003.php(%d) 126 | 127 | Arg value Array 128 | Error: 8192 - Function spliti() is deprecated, %s(73) 129 | Error: 2 - spliti() expects parameter 3 to be integer, array given, %s(73) 130 | NULL 131 | Error: 8 - Array to string conversion, %sspliti_variation_003.php(%d) 132 | 133 | Arg value Array 134 | Error: 8192 - Function spliti() is deprecated, %s(73) 135 | Error: 2 - spliti() expects parameter 3 to be integer, array given, %s(73) 136 | NULL 137 | Error: 8 - Array to string conversion, %sspliti_variation_003.php(%d) 138 | 139 | Arg value Array 140 | Error: 8192 - Function spliti() is deprecated, %s(73) 141 | Error: 2 - spliti() expects parameter 3 to be integer, array given, %s(73) 142 | NULL 143 | Error: 8 - Array to string conversion, %sspliti_variation_003.php(%d) 144 | 145 | Arg value Array 146 | Error: 8192 - Function spliti() is deprecated, %s(73) 147 | Error: 2 - spliti() expects parameter 3 to be integer, array given, %s(73) 148 | NULL 149 | 150 | Arg value 151 | Error: 8192 - Function spliti() is deprecated, %s(73) 152 | array(1) { 153 | [0]=> 154 | string(9) "1 2 3 4 5" 155 | } 156 | 157 | Arg value 158 | Error: 8192 - Function spliti() is deprecated, %s(73) 159 | array(1) { 160 | [0]=> 161 | string(9) "1 2 3 4 5" 162 | } 163 | 164 | Arg value 1 165 | Error: 8192 - Function spliti() is deprecated, %s(73) 166 | array(1) { 167 | [0]=> 168 | string(9) "1 2 3 4 5" 169 | } 170 | 171 | Arg value 172 | Error: 8192 - Function spliti() is deprecated, %s(73) 173 | array(1) { 174 | [0]=> 175 | string(9) "1 2 3 4 5" 176 | } 177 | 178 | Arg value 1 179 | Error: 8192 - Function spliti() is deprecated, %s(73) 180 | array(1) { 181 | [0]=> 182 | string(9) "1 2 3 4 5" 183 | } 184 | 185 | Arg value 186 | Error: 8192 - Function spliti() is deprecated, %s(73) 187 | array(1) { 188 | [0]=> 189 | string(9) "1 2 3 4 5" 190 | } 191 | 192 | Arg value 193 | Error: 8192 - Function spliti() is deprecated, %s(73) 194 | Error: 2 - spliti() expects parameter 3 to be integer, string given, %s(73) 195 | NULL 196 | 197 | Arg value 198 | Error: 8192 - Function spliti() is deprecated, %s(73) 199 | Error: 2 - spliti() expects parameter 3 to be integer, string given, %s(73) 200 | NULL 201 | 202 | Arg value string 203 | Error: 8192 - Function spliti() is deprecated, %s(73) 204 | Error: 2 - spliti() expects parameter 3 to be integer, string given, %s(73) 205 | NULL 206 | 207 | Arg value string 208 | Error: 8192 - Function spliti() is deprecated, %s(73) 209 | Error: 2 - spliti() expects parameter 3 to be integer, string given, %s(73) 210 | NULL 211 | Error: 4096 - Object of class stdClass could not be converted to string, %s(72) 212 | 213 | Arg value 214 | Error: 8192 - Function spliti() is deprecated, %s(73) 215 | Error: 2 - spliti() expects parameter 3 to be integer, object given, %s(73) 216 | NULL 217 | 218 | Arg value 219 | Error: 8192 - Function spliti() is deprecated, %s(73) 220 | array(1) { 221 | [0]=> 222 | string(9) "1 2 3 4 5" 223 | } 224 | 225 | Arg value 226 | Error: 8192 - Function spliti() is deprecated, %s(73) 227 | array(1) { 228 | [0]=> 229 | string(9) "1 2 3 4 5" 230 | } 231 | Done -------------------------------------------------------------------------------- /regex/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "utils.h" 10 | #include "regex2.h" 11 | #include "debug.ih" 12 | 13 | /* 14 | - regprint - print a regexp for debugging 15 | == void regprint(regex_t *r, FILE *d); 16 | */ 17 | void 18 | regprint(r, d) 19 | regex_t *r; 20 | FILE *d; 21 | { 22 | register struct re_guts *g = r->re_g; 23 | register int i; 24 | register int c; 25 | register int last; 26 | int nincat[NC]; 27 | 28 | fprintf(d, "%ld states, %d categories", (long)g->nstates, 29 | g->ncategories); 30 | fprintf(d, ", first %ld last %ld", (long)g->firststate, 31 | (long)g->laststate); 32 | if (g->iflags&USEBOL) 33 | fprintf(d, ", USEBOL"); 34 | if (g->iflags&USEEOL) 35 | fprintf(d, ", USEEOL"); 36 | if (g->iflags&BAD) 37 | fprintf(d, ", BAD"); 38 | if (g->nsub > 0) 39 | fprintf(d, ", nsub=%ld", (long)g->nsub); 40 | if (g->must != NULL) 41 | fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen, 42 | g->must); 43 | if (g->backrefs) 44 | fprintf(d, ", backrefs"); 45 | if (g->nplus > 0) 46 | fprintf(d, ", nplus %ld", (long)g->nplus); 47 | fprintf(d, "\n"); 48 | s_print(g, d); 49 | for (i = 0; i < g->ncategories; i++) { 50 | nincat[i] = 0; 51 | for (c = CHAR_MIN; c <= CHAR_MAX; c++) 52 | if (g->categories[c] == i) 53 | nincat[i]++; 54 | } 55 | fprintf(d, "cc0#%d", nincat[0]); 56 | for (i = 1; i < g->ncategories; i++) 57 | if (nincat[i] == 1) { 58 | for (c = CHAR_MIN; c <= CHAR_MAX; c++) 59 | if (g->categories[c] == i) 60 | break; 61 | fprintf(d, ", %d=%s", i, regchar(c)); 62 | } 63 | fprintf(d, "\n"); 64 | for (i = 1; i < g->ncategories; i++) 65 | if (nincat[i] != 1) { 66 | fprintf(d, "cc%d\t", i); 67 | last = -1; 68 | for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ 69 | if (c <= CHAR_MAX && g->categories[c] == i) { 70 | if (last < 0) { 71 | fprintf(d, "%s", regchar(c)); 72 | last = c; 73 | } 74 | } else { 75 | if (last >= 0) { 76 | if (last != c-1) 77 | fprintf(d, "-%s", 78 | regchar(c-1)); 79 | last = -1; 80 | } 81 | } 82 | fprintf(d, "\n"); 83 | } 84 | } 85 | 86 | /* 87 | - s_print - print the strip for debugging 88 | == static void s_print(register struct re_guts *g, FILE *d); 89 | */ 90 | static void 91 | s_print(g, d) 92 | register struct re_guts *g; 93 | FILE *d; 94 | { 95 | register sop *s; 96 | register cset *cs; 97 | register int i; 98 | register int done = 0; 99 | register sop opnd; 100 | register int col = 0; 101 | register int last; 102 | register sopno offset = 2; 103 | # define GAP() { if (offset % 5 == 0) { \ 104 | if (col > 40) { \ 105 | fprintf(d, "\n\t"); \ 106 | col = 0; \ 107 | } else { \ 108 | fprintf(d, " "); \ 109 | col++; \ 110 | } \ 111 | } else \ 112 | col++; \ 113 | offset++; \ 114 | } 115 | 116 | if (OP(g->strip[0]) != OEND) 117 | fprintf(d, "missing initial OEND!\n"); 118 | for (s = &g->strip[1]; !done; s++) { 119 | opnd = OPND(*s); 120 | switch (OP(*s)) { 121 | case OEND: 122 | fprintf(d, "\n"); 123 | done = 1; 124 | break; 125 | case OCHAR: 126 | if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL) 127 | fprintf(d, "\\%c", (unsigned char)opnd); 128 | else 129 | fprintf(d, "%s", regchar((unsigned char)opnd)); 130 | break; 131 | case OBOL: 132 | fprintf(d, "^"); 133 | break; 134 | case OEOL: 135 | fprintf(d, "$"); 136 | break; 137 | case OBOW: 138 | fprintf(d, "\\{"); 139 | break; 140 | case OEOW: 141 | fprintf(d, "\\}"); 142 | break; 143 | case OANY: 144 | fprintf(d, "."); 145 | break; 146 | case OANYOF: 147 | fprintf(d, "[(%ld)", (long)opnd); 148 | cs = &g->sets[opnd]; 149 | last = -1; 150 | for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */ 151 | if (CHIN(cs, i) && i < g->csetsize) { 152 | if (last < 0) { 153 | fprintf(d, "%s", regchar(i)); 154 | last = i; 155 | } 156 | } else { 157 | if (last >= 0) { 158 | if (last != i-1) 159 | fprintf(d, "-%s", 160 | regchar(i-1)); 161 | last = -1; 162 | } 163 | } 164 | fprintf(d, "]"); 165 | break; 166 | case OBACK_: 167 | fprintf(d, "(\\<%ld>", (long)opnd); 168 | break; 169 | case O_BACK: 170 | fprintf(d, "<%ld>\\)", (long)opnd); 171 | break; 172 | case OPLUS_: 173 | fprintf(d, "(+"); 174 | if (OP(*(s+opnd)) != O_PLUS) 175 | fprintf(d, "<%ld>", (long)opnd); 176 | break; 177 | case O_PLUS: 178 | if (OP(*(s-opnd)) != OPLUS_) 179 | fprintf(d, "<%ld>", (long)opnd); 180 | fprintf(d, "+)"); 181 | break; 182 | case OQUEST_: 183 | fprintf(d, "(?"); 184 | if (OP(*(s+opnd)) != O_QUEST) 185 | fprintf(d, "<%ld>", (long)opnd); 186 | break; 187 | case O_QUEST: 188 | if (OP(*(s-opnd)) != OQUEST_) 189 | fprintf(d, "<%ld>", (long)opnd); 190 | fprintf(d, "?)"); 191 | break; 192 | case OLPAREN: 193 | fprintf(d, "((<%ld>", (long)opnd); 194 | break; 195 | case ORPAREN: 196 | fprintf(d, "<%ld>))", (long)opnd); 197 | break; 198 | case OCH_: 199 | fprintf(d, "<"); 200 | if (OP(*(s+opnd)) != OOR2) 201 | fprintf(d, "<%ld>", (long)opnd); 202 | break; 203 | case OOR1: 204 | if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) 205 | fprintf(d, "<%ld>", (long)opnd); 206 | fprintf(d, "|"); 207 | break; 208 | case OOR2: 209 | fprintf(d, "|"); 210 | if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) 211 | fprintf(d, "<%ld>", (long)opnd); 212 | break; 213 | case O_CH: 214 | if (OP(*(s-opnd)) != OOR1) 215 | fprintf(d, "<%ld>", (long)opnd); 216 | fprintf(d, ">"); 217 | break; 218 | default: 219 | fprintf(d, "!%ld(%ld)!", OP(*s), opnd); 220 | break; 221 | } 222 | if (!done) 223 | GAP(); 224 | } 225 | } 226 | 227 | /* 228 | - regchar - make a character printable 229 | == static char *regchar(int ch); 230 | */ 231 | static unsigned char * /* -> representation */ 232 | regchar(ch) 233 | int ch; 234 | { 235 | static unsigned char buf[10]; 236 | 237 | if (isprint(ch) || ch == ' ') 238 | sprintf(buf, "%c", ch); 239 | else 240 | sprintf(buf, "\\%o", ch); 241 | return(buf); 242 | } 243 | --------------------------------------------------------------------------------