You're making it quite ugly. Why not use tsrm_strtok_r() which is just like strtok_r() but available everywhere?

Andi

At 03:43 PM 12/16/2002 +0000, Ilia Alshanetsky wrote:
iliaa Mon Dec 16 10:43:53 2002 EDT

Modified files:
/php4/main main.c
Log:
A better, strtok() free implementaion of php_disable_functions().


Index: php4/main/main.c
diff -u php4/main/main.c:1.519 php4/main/main.c:1.520
--- php4/main/main.c:1.519 Thu Dec 5 16:53:25 2002
+++ php4/main/main.c Mon Dec 16 10:43:52 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: main.c,v 1.519 2002/12/05 21:53:25 helly Exp $ */
+/* $Id: main.c,v 1.520 2002/12/16 15:43:52 iliaa Exp $ */

/* {{{ includes
*/
@@ -168,15 +168,36 @@
*/
static void php_disable_functions(TSRMLS_D)
{
- char *func;
- char *new_value_dup = strdup(INI_STR("disable_functions")); /* This is an intentional leak,
- * it's not a big deal as it's process-wide
- */
-
- func = strtok(new_value_dup, ", ");
- while (func) {
- zend_disable_function(func, strlen(func) TSRMLS_CC);
- func = strtok(NULL, ", ");
+ char *s = NULL;
+ char *e = INI_STR("disable_functions");
+ char p;
+
+ if (!*e) {
+ return;
+ }
+
+ while (*e) {
+ switch (*e) {
+ case ' ':
+ case ',':
+ if (s) {
+ p = *e;
+ *e = '\0';
+ zend_disable_function(s, e-s TSRMLS_CC);
+ *e = p;
+ s = NULL;
+ }
+ break;
+ default:
+ if (!s) {
+ s = e;
+ }
+ break;
+ }
+ e++;
+ }
+ if (s) {
+ zend_disable_function(s, e-s TSRMLS_CC);
}
}
/* }}} */



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to