]> granicus.if.org Git - php/commitdiff
@- ucfirst()/ucwords() no longer modify arg1. (Thies)
authorThies C. Arntzen <thies@php.net>
Sun, 14 Nov 1999 17:20:56 +0000 (17:20 +0000)
committerThies C. Arntzen <thies@php.net>
Sun, 14 Nov 1999 17:20:56 +0000 (17:20 +0000)
(PHP ucfirst,ucwords) no longer modify arg1

ext/standard/string.c

index 13a563ff36fd2c5f34f7eda980e4098c25784510..37e84725950df2f497db91faf34d5c0dfd6eb018 100644 (file)
@@ -937,8 +937,10 @@ PHP_FUNCTION(ucfirst)
        if (!*(*arg)->value.str.val) {
                RETURN_FALSE;
        }
-       *(*arg)->value.str.val = toupper((unsigned char)*(*arg)->value.str.val);
-       RETVAL_STRING((*arg)->value.str.val,1);
+
+       *return_value=**arg;
+       zval_copy_ctor(return_value);
+       *return_value->value.str.val = toupper((unsigned char)*return_value->value.str.val);
 }
 /* }}} */
 
@@ -957,8 +959,11 @@ PHP_FUNCTION(ucwords)
        if (!*(*arg)->value.str.val) {
                RETURN_FALSE;
        }
-       *(*arg)->value.str.val = toupper((unsigned char)*(*arg)->value.str.val);
-       r=(*arg)->value.str.val;
+       *return_value=**arg;
+       zval_copy_ctor(return_value);
+       *return_value->value.str.val = toupper((unsigned char)*return_value->value.str.val);
+
+       r=return_value->value.str.val;
        while((r=strstr(r," "))){
                if(*(r+1)){
                        r++;
@@ -967,7 +972,6 @@ PHP_FUNCTION(ucwords)
                        break;
                }
        }
-       RETVAL_STRING((*arg)->value.str.val,1);
 }
 /* }}} */