ircmaxell/php-src — pull request #5 by weltling (2013-08-17 17:22:30+00:00)
Title: String size refactor take 2, partial fixes to ext/standard

Not everything working yet, but many things do. Special emphasis has to be paid to signed/unsigned arithmetic, like substr(). ext/standard is still in progress, but important things work. About size_t and an unsigned type, a small snippet

int i = -11;
unsigned u = 10;

then

(u > i) == 0;
u - i == UINT_MAX

In every operation an unsigned operand will have precedence and the signed one will first be converted to the correspanding unsigned, in case the unsigned one was negative it'll become nearly the unsigned type max. Working with this needs clear understanding how to do math on signed/unsigned integers. Like in the case of substr(), i've tried to avoid the casts, but later or earlier there's no chance to pass by on those.