On 3/14/19 1:43 PM, Akim Demaille wrote: > > But maybe this piece of code is obsolete anyway? I mean, currently mbsnwidth > returns an int anyway, and seems to deal with overflow by itself. So I guess > we don't even need this precaution today.
That's right. add_column_width was originally written when mbsnwidth did not detect overflow, and so that precaution was present (whether correctly implemented or not, doesn't matter now). Nowadays we can remove the precautioin. > + return column <= INT_MAX - width ? column + width : INT_MAX; Nowadays a better (i.e., more-efficient, and I think easier-to-follow) way of writing this is: int result; return INT_ADD_WRAPV (column, width, &result) : INT_MAX : result; where INT_ADD_WRAPV is defined in intprops.h.
