[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Text input broken



In message <44363964.6020207@xxxxxxxx>
          Luke Hart <lukeh@xxxxxxxx> wrote:

> Martin Wuerthner wrote:
> 
>>Find attached a patch (patch17.txt) to fix the fix - you should not
>>pass a NULL state to mbrtowc. It is much better to pass a state
>>initialised to 0 because that is well-defined.
>> 
>>
> This surprises me since the manual says "In all of the above cases, if
> ps is a NULL pointer, a static anonymous state  only  known to the
> mbrtowc function is used instead.", which sounded exactly like what was
> needed! If your fix actually works though, it's much better than
> following what the man-page said!

To me, it sounded as if the behaviour was more or less undefined. But 
thinking more about it, I probably misunderstood what the man page 
said. Do you think it means that the mbrtowc function simply keeps its 
own private state which is guaranteed to be preserved between calls? 
That would do the right thing (except when multiple threads tried to 
use it simultaneously). In that case, your fix was correct and patch17 
should be reverted. Apologies.

Of course, calling the MultiByteToUnicode function on a Unicode build 
was wrong in the first place, which is the reason why your fix made 
things worse (because what we passed to the function were not really 
bytes of a multi-byte stream), and which is what patch18 fixed.

Martin