]> granicus.if.org Git - php/commitdiff
- Internal functions which are basic language functions should be in Zend
authorAndi Gutmans <andi@php.net>
Mon, 20 Sep 1999 16:56:02 +0000 (16:56 +0000)
committerAndi Gutmans <andi@php.net>
Mon, 20 Sep 1999 16:56:02 +0000 (16:56 +0000)
  and not in PHP. I.e. strlen(), each(), error_reporting(), count(),
  get_class_name().

ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/php3_string.h
ext/standard/string.c
main/php.h
tests/testarray

index e75f0f4ff4f74838fba86ec7233856133be93ba3..14e877f761b1feef771b53f70ec8df5abb4eae4e 100644 (file)
@@ -100,7 +100,6 @@ function_entry basic_functions[] = {
        PHP_FE(reset,                                                                   first_arg_force_ref)
        PHP_FE(current,                                                                 first_arg_force_ref)
        PHP_FE(key,                                                                     first_arg_force_ref)
-       PHP_FE(each,                                                                    first_arg_force_ref)
        PHP_FALIAS(pos,                         current,                        first_arg_force_ref)
        
        PHP_FE(time,                                                                    NULL)
@@ -137,11 +136,8 @@ function_entry basic_functions[] = {
        PHP_FE(phpversion,                                                              NULL)
        PHP_FE(phpcredits,                                                              NULL)
        
-       PHP_FE(strlen,                                                                  NULL)
-       PHP_FE(strcmp,                                                                  NULL)
        PHP_FE(strspn,                                                                  NULL)
        PHP_FE(strcspn,                                                                 NULL)
-       PHP_FE(strcasecmp,                                                              NULL)
        PHP_FE(strtok,                                                                  NULL)
        PHP_FE(strtoupper,                                                              NULL)
        PHP_FE(strtolower,                                                              NULL)
@@ -217,8 +213,6 @@ function_entry basic_functions[] = {
        PHP_FE(getmxrr,                                                                 second_and_third_args_force_ref)
 #endif
 
-       PHP_FE(error_reporting,                                                 NULL)
-
        PHP_FE(getmyuid,                                                                NULL)
        PHP_FE(getmypid,                                                                NULL)
        PHP_FE(getmyinode,                                                              NULL)
@@ -557,30 +551,6 @@ PHP_FUNCTION(putenv)
 #endif
 
 
-PHP_FUNCTION(error_reporting)
-{
-       pval *arg;
-       int old_error_reporting;
-       ELS_FETCH();
-
-       old_error_reporting = EG(error_reporting);
-       switch (ARG_COUNT(ht)) {
-               case 0:
-                       break;
-               case 1:
-                       if (getParameters(ht,1,&arg) == FAILURE) {
-                               RETURN_FALSE;
-                       }
-                       convert_to_long(arg);
-                       EG(error_reporting)=arg->value.lval;
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-                       break;
-       }
-       
-       RETVAL_LONG(old_error_reporting);
-}
 
 PHP_FUNCTION(toggle_short_open_tag)
 {
@@ -1098,58 +1068,6 @@ PHP_FUNCTION(next)
        pval_copy_constructor(return_value);
 }
 
-
-PHP_FUNCTION(each)
-{
-       pval *array,*entry,**entry_ptr, *tmp;
-       char *string_key;
-       ulong num_key;
-       pval **inserted_pointer;
-       HashTable *target_hash;
-       
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       target_hash = HASH_OF(array);
-       if (!target_hash) {
-               php_error(E_WARNING,"Variable passed to each() is not an array or object");
-               return;
-       }
-       if (zend_hash_get_current_data(target_hash, (void **) &entry_ptr)==FAILURE) {
-               RETURN_FALSE;
-       }
-       array_init(return_value);
-       entry = *entry_ptr;
-
-       /* add value elements */
-       if (entry->EA.is_ref) {
-               tmp = (pval *)emalloc(sizeof(pval));
-               *tmp = *entry;
-               pval_copy_constructor(tmp);
-               tmp->EA.is_ref=0;
-               tmp->EA.locks = 0;
-               tmp->refcount=0;
-               entry=tmp;
-       }
-       zend_hash_index_update(return_value->value.ht, 1, &entry, sizeof(pval *), NULL);
-       entry->refcount++;
-       zend_hash_update_ptr(return_value->value.ht, "value", sizeof("value"), entry, sizeof(pval *), NULL);
-       entry->refcount++;
-
-       /* add the key elements */
-       switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
-               case HASH_KEY_IS_STRING:
-                       add_get_index_string(return_value,0,string_key,(void **) &inserted_pointer,0);
-                       break;
-               case HASH_KEY_IS_LONG:
-                       add_get_index_long(return_value,0,num_key, (void **) &inserted_pointer);
-                       break;
-       }
-       zend_hash_update(return_value->value.ht, "key", sizeof("key"), inserted_pointer, sizeof(pval *), NULL);
-       (*inserted_pointer)->refcount++;
-       zend_hash_move_forward(target_hash);
-}
-
        
 PHP_FUNCTION(reset)
 {
index d33a5559c8ad189e8452445c244f9192ce4a42d7..967f45b2d372d054559357a72e22f1646f65152c 100644 (file)
@@ -64,7 +64,6 @@ PHP_FUNCTION(flush);
 PHP_FUNCTION(end);
 PHP_FUNCTION(prev);
 PHP_FUNCTION(next);
-PHP_FUNCTION(each);
 PHP_FUNCTION(reset);
 PHP_FUNCTION(current);
 PHP_FUNCTION(key);
@@ -76,7 +75,6 @@ PHP_FUNCTION(max);
 /* system functions */
 PHP_FUNCTION(getenv);
 PHP_FUNCTION(putenv);
-PHP_FUNCTION(error_reporting);
 
 PHP_FUNCTION(get_current_user);
 PHP_FUNCTION(set_time_limit);
index 7d8bda4903cea84555669d6f85cff471786a3e71..725364af6bfe9650f9d25376d51e28437ab3c668 100644 (file)
 extern char *strtok_string;
 #endif
 
-PHP_FUNCTION(strlen);
-PHP_FUNCTION(strcmp);
 PHP_FUNCTION(strspn);
 PHP_FUNCTION(strcspn);
-PHP_FUNCTION(strcasecmp);
 PHP_FUNCTION(str_replace);
 PHP_FUNCTION(chop);
 PHP_FUNCTION(trim);
index 066ccf4a0022993cc9b265406917397f36ce882b..3058239b59db203c2e7504f2e1cb932b9c5402ee 100644 (file)
@@ -78,49 +78,6 @@ PHP_FUNCTION(bin2hex)
        RETURN_STRINGL(new, newlen, 0);
 }
 
-/* {{{ proto int strlen(string str)
-   Get string length */
-PHP_FUNCTION(strlen)
-{
-       pval **str;
-       
-       if (ARG_COUNT(ht) != 1 || getParametersEx(1, &str) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string_ex(str);
-       RETVAL_LONG((*str)->value.str.len);
-}
-/* }}} */
-
-/* {{{ proto int strcmp(string str1, string str2)
-   Binary safe string comparison */
-PHP_FUNCTION(strcmp)
-{
-       pval *s1,*s2;
-       
-       if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string(s1);
-       convert_to_string(s2);
-       RETURN_LONG(php3_binary_strcmp(s1,s2));
-}
-/* }}} */
-
-/* {{{ proto int strcasecmp(string str1, string str2)
-   Binary safe case-insensitive string comparison */
-PHP_FUNCTION(strcasecmp)
-{
-       pval *s1,*s2;
-       
-       if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &s1, &s2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string(s1);
-       convert_to_string(s2);
-       RETURN_LONG(zend_binary_strcasecmp(s1, s2));
-}
-/* }}} */
 
 /* {{{ proto int strspn(string str, string mask)
    Find length of initial segment consisting entirely of characters found in mask */
index 2207dbce8db7d4c5324c3e64eb5bac87bc226160..4f635a21e86a0cd4c293ab534467e0556a63258f 100644 (file)
@@ -249,7 +249,6 @@ extern int ap_vsnprintf(char *, size_t, const char *, va_list);
 #define STR_FREE(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree(ptr); }
 #define COPY_STRING(yy)   (yy).value.str.val = (char *) estrndup((yy).value.str.val,(yy).value.str.len)
 #define STR_PRINT(str) ((str)?(str):"")
-#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
 
 #ifndef MAXPATHLEN
 #define MAXPATHLEN 256    /* Should be safe for any weird systems that do not define it */
index 27a2f9bc4d820d78be48bddb64617414ad575388..056bd2966bf376130d0bb4670bdd5c537cffcc41 100644 (file)
@@ -1,4 +1,3 @@
-
 This is a small test...
 
 <?