]> granicus.if.org Git - php/commitdiff
Fixed problems with the new nl2br() and beautified the code a little.
authorSander Roobol <sander@php.net>
Fri, 11 Oct 2002 12:42:01 +0000 (12:42 +0000)
committerSander Roobol <sander@php.net>
Fri, 11 Oct 2002 12:42:01 +0000 (12:42 +0000)
Closes #19858.

ext/standard/string.c

index 1f8db2a3bbb898e16531ce5d1a71ca4388eeb158..bb6f7a47e5e94a5ce19646cd916fe4004e62ab70 100644 (file)
@@ -3061,10 +3061,10 @@ PHP_FUNCTION(nl2br)
        }
        
        if (repl_cnt == 0) {
-               RETURN_STRINGL(str, Z_STRLEN_PP(zstr), 1);
+               RETURN_STRINGL(Z_STRVAL_PP(zstr), Z_STRLEN_PP(zstr), 1);
        }
 
-       new_length = Z_STRLEN_PP(zstr) + repl_cnt * 6;
+       new_length = Z_STRLEN_PP(zstr) + repl_cnt * (sizeof("<br />") - 1);
        tmp = target = emalloc(new_length + 1);
 
        str = Z_STRVAL_PP(zstr);
@@ -3091,7 +3091,7 @@ PHP_FUNCTION(nl2br)
                str++;
        }
        
-       *target = 0;
+       *target = '\0';
 
        RETURN_STRINGL(tmp, new_length, 0);
 }