diff options
author | Derick Rethans <derick@php.net> | 2001-09-09 11:42:36 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2001-09-09 11:42:36 +0000 |
commit | 176cd90bd732337d35f993d7329b02e78d52b0ed (patch) | |
tree | b2b3184258e820e56d7a05a9adea7780fd750656 | |
parent | ff2bc83c085051ddb784d6f2c9010c1cce1aa0e5 (diff) | |
download | php-git-176cd90bd732337d35f993d7329b02e78d52b0ed.tar.gz |
- Fix for bug 11904
#- This is possibly not the best solution... feel free to improve
-rw-r--r-- | ext/standard/string.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index fb56de4b39..de550c451c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2978,14 +2978,27 @@ PHP_FUNCTION(hebrevc) PHP_FUNCTION(nl2br) { zval **str; + char* tmp; + int new_length; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &str)==FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); - - php_char_to_str((*str)->value.str.val, (*str)->value.str.len,'\n', "<br />\n", 7, return_value); + + /* Windows style line-endings */ + tmp = boyer_str_to_str((*str)->value.str.val, (*str)->value.str.len, "\r\n", 2, "<br />\r\n", 8, &new_length); + if (new_length != (*str)->value.str.len) + RETURN_STRINGL (tmp, new_length, 0); + efree (tmp); + /* Mac style line-endings */ + tmp = boyer_str_to_str((*str)->value.str.val, (*str)->value.str.len, "\n\r", 2, "<br />\n\r", 8, &new_length); + if (new_length != (*str)->value.str.len) + RETURN_STRINGL (tmp, new_length, 0); + efree (tmp); + /* Unix style line-endings */ + php_char_to_str((*str)->value.str.val,(*str)->value.str.len, '\n',"<br />\n", 7, return_value); } /* }}} */ |