cvs: php4 /ext/standard basic_functions.c reg.c reg.h
| From: | Thies C. Arntzen | Date: | Fri, 23 Jun 2000 11:48:02 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c reg.c reg.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-399@lists.php.net to get a copy of this message | ||
thies Fri Jun 23 04:48:02 2000 EDT
Modified files:
/php4/ext/standard basic_functions.c reg.c reg.h
Log:
@- added spliti() function. (Thies)
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.219 php4/ext/standard/basic_functions.c:1.220
--- php4/ext/standard/basic_functions.c:1.219 Wed Jun 21 15:51:29 2000
+++ php4/ext/standard/basic_functions.c Fri Jun 23 04:48:02 2000
@@ -346,6 +346,7 @@
PHP_FE(eregi, third_argument_force_ref)
PHP_FE(eregi_replace, NULL)
PHP_FE(split, NULL)
+ PHP_FE(spliti, NULL)
PHP_FALIAS(join, implode, NULL)
PHP_FE(sql_regcase, NULL)
Index: php4/ext/standard/reg.c
diff -u php4/ext/standard/reg.c:1.36 php4/ext/standard/reg.c:1.37
--- php4/ext/standard/reg.c:1.36 Mon Jun 5 12:47:44 2000
+++ php4/ext/standard/reg.c Fri Jun 23 04:48:02 2000
@@ -17,7 +17,7 @@
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
+----------------------------------------------------------------------+
*/
-/* $Id: reg.c,v 1.36 2000/06/05 19:47:44 andi Exp $ */
+/* $Id: reg.c,v 1.37 2000/06/23 11:48:02 thies Exp $ */
#include <stdio.h>
#include "php.h"
@@ -492,17 +492,16 @@
}
/* }}} */
-/* ("root", "passwd", "uid", "gid",
"other:stuff:like:/bin/sh")
- = split(":", $passwd_file, 5); */
-/* {{{ proto array split(string pattern, string string [, int limit])
- Split string into array by regular expression */
-PHP_FUNCTION(split)
+static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
{
pval **spliton, **str, **arg_count = NULL;
regex_t re;
regmatch_t subs[1];
char *strp, *endp;
- int err, size, count;
+ int err, size, count, copts = 0;
+
+ if (icase)
+ copts = REG_ICASE;
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -526,7 +525,7 @@
strp = (*str)->value.str.val;
endp = (*str)->value.str.val + strlen((*str)->value.str.val);
- err = regcomp(&re, (*spliton)->value.str.val, REG_EXTENDED);
+ err = regcomp(&re, (*spliton)->value.str.val, REG_EXTENDED | copts);
if (err) {
php_error(E_WARNING, "unexpected regex error (%d)", err);
RETURN_FALSE;
@@ -586,10 +585,30 @@
add_next_index_stringl(return_value, strp, size, 1);
regfree(&re);
+}
+
+/* ("root", "passwd", "uid", "gid",
"other:stuff:like:/bin/sh")
+ = split(":", $passwd_file, 5); */
+/* {{{ proto array split(string pattern, string string [, int limit])
+ Split string into array by regular expression */
+
+PHP_FUNCTION(split)
+{
+ php_split(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
- return;
+/* }}} */
+
+/* {{{ proto array spliti(string pattern, string string [, int limit])
+ Split string into array by regular expression case-insensitive */
+
+PHP_FUNCTION(spliti)
+{
+ php_split(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
+
/* }}} */
+
/* {{{ proto string sql_regcase(string string)
Make regular expression for case insensitive match */
Index: php4/ext/standard/reg.h
diff -u php4/ext/standard/reg.h:1.7 php4/ext/standard/reg.h:1.8
--- php4/ext/standard/reg.h:1.7 Mon Mar 6 12:37:11 2000
+++ php4/ext/standard/reg.h Fri Jun 23 04:48:02 2000
@@ -28,7 +28,7 @@
*/
-/* $Id: reg.h,v 1.7 2000/03/06 20:37:11 ssb Exp $ */
+/* $Id: reg.h,v 1.8 2000/06/23 11:48:02 thies Exp $ */
#ifndef _REG_H
#define _REG_H
@@ -40,6 +40,7 @@
PHP_FUNCTION(eregi_replace);
PHP_FUNCTION(ereg_replace);
PHP_FUNCTION(split);
+PHP_FUNCTION(spliti);
PHPAPI PHP_FUNCTION(sql_regcase);
typedef struct {