CVS update: php31/ext/standard
| From: | shane | Date: | Fri, 14 Aug 1998 05:10:00 +0000 |
| Subject: | CVS update: php31/ext/standard | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-208@lists.php.net to get a copy of this message | ||
Date: Friday August 14, 1998 @ 1:10
Author: shane
Update of /repository/php31/ext/standard
In directory asf:/tmp/cvs-serv18590/ext/standard
Modified Files:
basic_functions.c basic_functions.h php3_string.h
Log Message:
3.0->3.1 patches
Index: php31/ext/standard/basic_functions.c
diff -c php31/ext/standard/basic_functions.c:2.3 php31/ext/standard/basic_functions.c:2.4
*** php31/ext/standard/basic_functions.c:2.3 Fri Jul 17 13:23:09 1998
--- php31/ext/standard/basic_functions.c Fri Aug 14 01:09:59 1998
***************
*** 81,88 ****
#if PHP_DEBUGGER
extern int _php3_send_error(char *message, char *address);
#endif
!
!
function_entry basic_functions[] = {
{"intval", int_value, NULL},
--- 81,89 ----
#if PHP_DEBUGGER
extern int _php3_send_error(char *message, char *address);
#endif
! /*FIXME THREAD SAFETY!!!*/
! static pval *user_compare_func_name;
! static HashTable *user_shutdown_function_names;
function_entry basic_functions[] = {
{"intval", int_value, NULL},
***************
*** 98,103 ****
--- 99,106 ----
{"arsort", php3_arsort, first_arg_force_ref},
{"sort", php3_sort, first_arg_force_ref},
{"rsort", php3_rsort, first_arg_force_ref},
+ {"usort", php3_user_sort, first_arg_force_ref},
+ {"array_walk", php3_array_walk, first_arg_force_ref},
{"sizeof", php3_count, first_arg_allow_ref},
{"count", php3_count, first_arg_allow_ref},
{"time", php3_time, NULL},
***************
*** 145,150 ****
--- 148,156 ----
{"phpversion", php3_version, NULL},
{"strlen", php3_strlen, NULL},
{"strcmp", php3_strcmp, NULL},
+ {"strspn", php3_strspn, NULL},
+ {"strcspn", php3_strcspn, NULL},
+ {"strcasecmp", php3_strcasecmp, NULL},
{"strtok", php3_strtok, NULL},
{"strtoupper", php3_strtoupper, NULL},
{"strtolower", php3_strtolower, NULL},
***************
*** 167,172 ****
--- 173,179 ----
{"rawurlencode", php3_rawurlencode, NULL},
{"rawurldecode", php3_rawurldecode, NULL},
{"ucfirst", php3_ucfirst, NULL},
+ {"ucwords", php3_ucwords, NULL},
{"strtr", php3_strtr, NULL},
{"sprintf", php3_user_sprintf, NULL},
{"printf", php3_user_printf, NULL},
***************
*** 253,258 ****
--- 260,270 ----
{"leak", php3_leak, NULL},
{"error_log", php3_error_log, NULL},
+ {"call_user_func", php3_call_user_func, NULL},
+ {"call_user_method", php3_call_user_method, NULL},
+
+ PHP3_FE(register_shutdown_function, NULL)
+
{NULL, NULL, NULL}
};
***************
*** 299,304 ****
--- 311,318 ----
return FAILURE;
}
#endif
+ user_compare_func_name=NULL;
+ user_shutdown_function_names=NULL;
return SUCCESS;
}
***************
*** 309,314 ****
--- 323,332 ----
#if HAVE_PUTENV && !defined(THREAD_SAFE)
_php3_hash_destroy(&putenv_ht);
#endif
+ if (user_shutdown_function_names) {
+ _php3_hash_destroy(user_shutdown_function_names);
+ efree(user_shutdown_function_names);
+ }
return SUCCESS;
}
***************
*** 706,711 ****
--- 724,779 ----
RETURN_TRUE;
}
+ static pval *user_compare_func_name;
+
+ static int array_user_compare(const void *a, const void *b)
+ {
+ Bucket *f;
+ Bucket *s;
+ pval *args[2];
+ pval retval;
+ TLS_VARS;
+
+ f = *((Bucket **) a);
+ s = *((Bucket **) b);
+
+ args[0] = (pval *) f->pData;
+ args[1] = (pval *) s->pData;
+
+ if (call_user_function(&GLOBAL(function_table), NULL, user_compare_func_name, &retval, 2,
args)==SUCCESS) {
+ convert_to_long(&retval);
+ return retval.value.lval;
+ } else {
+ return 0;
+ }
+ }
+
+
+ void php3_user_sort(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *array;
+ pval *old_compare_func;
+ TLS_VARS;
+
+ old_compare_func = user_compare_func_name;
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &user_compare_func_name) ==
FAILURE) {
+ user_compare_func_name = old_compare_func;
+ WRONG_PARAM_COUNT;
+ }
+ if (!(array->type & IS_HASH)) {
+ php3_error(E_WARNING, "Wrong datatype in usort() call");
+ user_compare_func_name = old_compare_func;
+ return;
+ }
+ convert_to_string(user_compare_func_name);
+ if (_php3_hash_sort(array->value.ht, array_user_compare, 1) == FAILURE) {
+ user_compare_func_name = old_compare_func;
+ return;
+ }
+ user_compare_func_name = old_compare_func;
+ RETURN_TRUE;
+ }
+
void array_end(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 968,974 ****
break;
case IS_OBJECT:
RETVAL_STRING("object",1);
! break;
default:
RETVAL_STRING("unknown type",1);
}
--- 1036,1042 ----
break;
case IS_OBJECT:
RETVAL_STRING("object",1);
! break;
default:
RETVAL_STRING("unknown type",1);
}
***************
*** 1073,1078 ****
--- 1141,1182 ----
}
}
+
+ static pval *php3_array_walk_func_name;
+
+ static int _php3_array_walk(const void *a)
+ {
+ pval *args[1];
+ pval retval;
+ TLS_VARS;
+
+ args[0] = (pval *)a;
+
+ call_user_function(&GLOBAL(function_table), NULL, php3_array_walk_func_name, &retval, 1,
args);
+ return 0;
+ }
+
+ void php3_array_walk(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *array, *old_walk_func_name;
+ TLS_VARS;
+
+ old_walk_func_name = php3_array_walk_func_name;
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &array, &php3_array_walk_func_name) ==
FAILURE) {
+ php3_array_walk_func_name = old_walk_func_name;
+ WRONG_PARAM_COUNT;
+ }
+ if (!(array->type & IS_HASH)) {
+ php3_error(E_WARNING, "Wrong datatype in array_walk() call");
+ php3_array_walk_func_name = old_walk_func_name;
+ return;
+ }
+ convert_to_string(php3_array_walk_func_name);
+ _php3_hash_apply(array->value.ht, (int (*)(void *))_php3_array_walk);
+ php3_array_walk_func_name = old_walk_func_name;
+ RETURN_TRUE;
+ }
+
+
#if 0
void php3_max(INTERNAL_FUNCTION_PARAMETERS)
{
***************
*** 1335,1340 ****
--- 1439,1531 ----
return SUCCESS;
}
+ void php3_call_user_func(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval **params;
+ pval retval;
+ int arg_count=ARG_COUNT(ht);
+ TLS_VARS;
+
+ if (arg_count<1) {
+ WRONG_PARAM_COUNT;
+ }
+ params = (pval **) emalloc(sizeof(pval)*arg_count);
+
+ if (getParametersArray(ht, arg_count, params)==FAILURE) {
+ efree(params);
+ RETURN_FALSE;
+ }
+ convert_to_string(params[0]);
+ if (call_user_function(&GLOBAL(function_table), NULL, params[0], &retval, arg_count-1,
params+1)==SUCCESS) {
+ *return_value = retval;
+ } else {
+ php3_error(E_WARNING,"Unable to call %s() - function does not exist",
params[0]->value.str.val);
+ }
+ efree(params);
+ }
+
+
+ void php3_call_user_method(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval **params;
+ pval retval;
+ int arg_count=ARG_COUNT(ht);
+ TLS_VARS;
+
+ if (arg_count<2) {
+ WRONG_PARAM_COUNT;
+ }
+ params = (pval **) emalloc(sizeof(pval)*arg_count);
+
+ if (getParametersArray(ht, arg_count, params)==FAILURE) {
+ efree(params);
+ RETURN_FALSE;
+ }
+ if (params[1]->type != IS_OBJECT) {
+ php3_error(E_WARNING,"2nd argument is not an object\n");
+ efree(params);
+ RETURN_FALSE;
+ }
+ convert_to_string(params[0]);
+ if (call_user_function(&GLOBAL(function_table), params[1], params[0], &retval,
arg_count-2, params+2)==SUCCESS) {
+ *return_value = retval;
+ } else {
+ php3_error(E_WARNING,"Unable to call %s() - function does not exist",
params[0]->value.str.val);
+ }
+ efree(params);
+ }
+
+ void user_shutdown_function_dtor(pval *user_shutdown_function_name)
+ {
+ pval retval;
+ TLS_VARS;
+
+ if (call_user_function(&GLOBAL(function_table), NULL, user_shutdown_function_name,
&retval, 0, NULL)==SUCCESS) {
+ yystype_destructor(&retval _INLINE_TLS);
+ }
+ yystype_destructor(user_shutdown_function_name _INLINE_TLS);
+ }
+
+
+ PHP3_FUNCTION(register_shutdown_function)
+ {
+ pval *arg, shutdown_function_name;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &arg)) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(arg);
+ if (!user_shutdown_function_names) {
+ user_shutdown_function_names = (HashTable *) emalloc(sizeof(HashTable));
+ _php3_hash_init(user_shutdown_function_names, 0, NULL, (void (*)(void
*))user_shutdown_function_dtor, 0);
+ }
+
+ shutdown_function_name = *arg;
+ yystype_copy_constructor(&shutdown_function_name);
+
+ _php3_hash_next_index_insert(user_shutdown_function_names, &shutdown_function_name,
sizeof(pval), NULL);
+ }
/*
* Local variables:
Index: php31/ext/standard/basic_functions.h
diff -c php31/ext/standard/basic_functions.h:2.0 php31/ext/standard/basic_functions.h:2.1
*** php31/ext/standard/basic_functions.h:2.0 Fri Jul 3 09:14:18 1998
--- php31/ext/standard/basic_functions.h Fri Aug 14 01:09:59 1998
***************
*** 29,35 ****
*/
! /* $Id: basic_functions.h,v 2.0 1998/07/03 13:14:18 rasmus Exp $ */
#ifndef _BASIC_FUNCTIONS_H
#define _BASIC_FUNCTIONS_H
--- 29,35 ----
*/
! /* $Id: basic_functions.h,v 2.1 1998/08/14 05:09:59 shane Exp $ */
#ifndef _BASIC_FUNCTIONS_H
#define _BASIC_FUNCTIONS_H
***************
*** 48,53 ****
--- 48,55 ----
extern void php3_key_sort(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_asort(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_arsort(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_user_sort(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_array_walk(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_sort(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_rsort(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_count(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 83,90 ****
--- 85,96 ----
extern void php3_is_object(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_leak(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_call_user_func(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_call_user_method(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_error_log(INTERNAL_FUNCTION_PARAMETERS);
+
+ PHP3_FUNCTION(register_shutdown_function);
#if HAVE_PUTENV
typedef struct {
Index: php31/ext/standard/php3_string.h
diff -c php31/ext/standard/php3_string.h:2.0 php31/ext/standard/php3_string.h:2.1
*** php31/ext/standard/php3_string.h:2.0 Fri Jul 3 09:14:34 1998
--- php31/ext/standard/php3_string.h Fri Aug 14 01:10:00 1998
***************
*** 29,35 ****
*/
! /* $Id: php3_string.h,v 2.0 1998/07/03 13:14:34 rasmus Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
--- 29,35 ----
*/
! /* $Id: php3_string.h,v 2.1 1998/08/14 05:10:00 shane Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
***************
*** 40,45 ****
--- 40,48 ----
extern void php3_strlen(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strcmp(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_strcasecmp(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_strspn(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_strcspn(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_chop(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_trim(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ltrim(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 59,64 ****
--- 62,68 ----
extern void php3_substr(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_quotemeta(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ucfirst(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_ucwords(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strtr(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_strrev(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_hebrev(INTERNAL_FUNCTION_PARAMETERS);
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net