tech-userlevel archive

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

Re: [PATCH] Support for mbsnrtowcs and wcsnrtomb



>>>>> On Fri, 26 Apr 2013 11:34:02 +0200,
      Joerg Sonnenberger <joerg%britannica.bec.de@localhost> said:

>> >> We should wait for the nozaki-san's recovery about other problems,
>> >> at very least.
>> 
>> > I don't mind.
>> 
>> You mean you will wait for the recovery?
>> That's great.

> It would be nice to get a review for the newlocale() patch as a bunch of
> broken high-profile applications can't deal with the existance of *_l
> without newlocale(), but mbsnrtowcs is not that critical.

I seemed to recall that he was worrying that recent changes broke
some coding policies of citrus.

>> >> > I'm also not sure if it is really correct, e.g. the (not) resetting
>> >> > of mbstate at the end of input.
>> >> 
>> >> Nozaki-san's implementation is corrent.
>> 
>> > I don't think it is. mbsnrtowcs is supposed to reset the the state (just
>> > like mbsrtowcs does) when it reaches the end of input.
>> 
>> It seems you are misunderstanding the existing code.
>> As you said, mbsnrtowcs() should behave just like mbsrtowcs() does.
>> And mbsrtowcs() DOES NOT RESET the state.
>> See lib/libc/citrus/modules/citrus_iso2022.c for example.

> Check the code in citrus_ctype_template.h for mbsrtowcs, specifically,
> the call to _FUNCNAME(init_state). That is required:
> 
> "If conversion stopped due to reaching a terminating null character, and
> if dst is not a null pointer, the resulting state described shall be the
> initial conversion state"
> 
> and this part is missing from Nozaki-san's implementation?

Ah, thanks.

I re-checked the specification of mbsrtowcs(), and found that I made
same mistake with nozaki-san's patch.
I thought mbrstowcs() just behaved like sequence of calls of mbrtowc(),
but actually it didn't, and mbrstowcs() could not be used as a
replacement of mbrtowc() calls.

So, in this specific part, your code is correct.
That doesn't mean not using nozaki-san's code is better, though.

We should compare the code to see which is better.
-- 
soda


Home | Main Index | Thread Index | Old Index