@@ -3028,6 +3028,7 @@ static void php_strtr_array_destroy_ppres(PPRES *d)
3028
3028
static void php_strtr_array_do_repl (STR * text , PPRES * d , zval * return_value )
3029
3029
{
3030
3030
STRLEN pos = 0 ,
3031
+ nextwpos = 0 ,
3031
3032
lastpos = L (text ) - d -> m ;
3032
3033
smart_str result = {0 };
3033
3034
@@ -3036,7 +3037,6 @@ static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value)
3036
3037
STRLEN shift = d -> shift -> entries [h ];
3037
3038
3038
3039
if (shift > 0 ) {
3039
- smart_str_appendl (& result , & S (text )[pos ], MIN (shift , L (text ) - pos ));
3040
3040
pos += shift ;
3041
3041
} else {
3042
3042
HASH h2 = h & d -> hash -> table_mask ,
@@ -3056,20 +3056,19 @@ static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value)
3056
3056
memcmp (S (& pnr -> pat ), & S (text )[pos ], L (& pnr -> pat )) != 0 )
3057
3057
continue ;
3058
3058
3059
- smart_str_appendl (& result , S (& pnr -> repl ), (int )L (& pnr -> repl ));
3059
+ smart_str_appendl (& result , & S (text )[nextwpos ], pos - nextwpos );
3060
+ smart_str_appendl (& result , S (& pnr -> repl ), L (& pnr -> repl ));
3060
3061
pos += L (& pnr -> pat );
3062
+ nextwpos = pos ;
3061
3063
goto end_outer_loop ;
3062
3064
}
3063
3065
3064
- smart_str_appendc (& result , S (text )[pos ]);
3065
3066
pos ++ ;
3066
3067
end_outer_loop : ;
3067
3068
}
3068
3069
}
3069
3070
3070
- if (pos < L (text )) {
3071
- smart_str_appendl (& result , & S (text )[pos ], (int )(L (text ) - pos ));
3072
- }
3071
+ smart_str_appendl (& result , & S (text )[nextwpos ], L (text ) - nextwpos );
3073
3072
3074
3073
if (result .c != NULL ) {
3075
3074
smart_str_0 (& result );
0 commit comments