On 2023-07-04 12:31, Bruno Haible wrote:
Yes.

As far as I can see, this proposed patch should cope with (size_t) -3
returns correctly.

I still see a couple of problems with it. First, it mishandles the case where mbrtoc32 returns 0, which ISO C allows.

Second and more interestingly, its "fwrite (tp0, 1, bytes, out);" could output a byte string that represents multiple characters where the first character fits in the output column width but the remaining characters do not, and this would exceed the output column width.

I suppose one could fix the second problem by not outputting such a byte string, just as the code already suppresses the output of a byte string representing a single character that occupies multiple columns straddling the column border. That is, count all the columns of all the characters that the byte string represents, before deciding whether to output the byte string.


Reply via email to