From: Andrei Zmievski Date: Tue, 18 Apr 2006 05:18:12 +0000 (+0000) Subject: I'm not sure what the heck people were thinking here, but it should be X-Git-Tag: RELEASE_1_3~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efd298e2ebc46e53317d89911df24333aed725c1;p=php I'm not sure what the heck people were thinking here, but it should be fixed finally. Please test. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 82761e8186..9788361e95 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -721,10 +721,12 @@ static UChar *php_u_trim(UChar *c, int len, UChar *what, int what_len, zval *ret } if ( wh != ch ) break; } else { - if ( u_isWhitespace(ch) == FALSE ) break; + if ( u_isWhitespace(ch) == FALSE ) { + U16_BACK_1(c, 0, i); /* U16_NEXT() post-increments 'i' */ + break; + } } } - U16_BACK_1(c, 0, i); /* U16_NEXT() post-increments 'i' */ start = i; } if ( mode & 2 ) { @@ -737,12 +739,13 @@ static UChar *php_u_trim(UChar *c, int len, UChar *what, int what_len, zval *ret } if ( wh != ch ) break; } else { - if ( u_isWhitespace(ch) == FALSE ) break; + if ( u_isWhitespace(ch) == FALSE ) { + U16_FWD_1(c, i, end); /* U16_PREV() pre-decrements 'i' */ + break; + } } } end = i; - } else { - --end; } if ( what ) { @@ -751,10 +754,10 @@ static UChar *php_u_trim(UChar *c, int len, UChar *what, int what_len, zval *ret if ( start < len ) { if ( return_value ) { - RETVAL_UNICODEL(c+start, end-start+1, 1); + RETVAL_UNICODEL(c+start, end-start, 1); return NULL; } else { - return eustrndup(c+start, end-start+1); + return eustrndup(c+start, end-start); } } else { /* Trimmed the whole string */ if ( return_value ) {