This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: %S %C vfprintf contribution


Artem,

A number of comments/issues:

  1. The tests for buf size vs MB_LEN_MAX shouldn't be needed.
     The lowest value is 40 and I don't think I want to see a character
     set that requires over 40 bytes to encode a single character. :)

  2. Your 'S' code ends up falling into the old strlen check for 's'.  You
     should prevent this by using an else clause.  Your check for cp is
     NULL should occur at the top just after setting cp.  Your S code can
     then be an else if and the old 's' code can be in an else clause.

  3. Your freeing of the widechar string buffer is not in the right spot.
     There is an error case that follows allocating the buffer so you won't
     free it.  You should also use a separate ptr other than cp for the
     malloc'd storage so there is no doubt you are freeing the right thing
     at the end.

-- Jeff J.

Artem B. Bityuckiy wrote:
Artem B. Bityuckiy wrote:

Hello.

Nicholas Wourms wrote:
> Artem B. Bityuckiy wrote:
>
>> Hello.
>>
>> Here is the patch that makes vfprintf (and hence, all other
>> vfprintf-based Xprintf functions) understand ISO C 90 %S (same as %ls)
>> and %C (same as %lc) format placeholders. Please, review it and give
>> us know if something is wrong.
>>
>> This is tested a little bit- it works and it seems should work with
>> any locale if wcrtomb and wcsrtomb functions work.
>>
>
> I believe the preferred patch type is unidiff or `diff -up`.
OK, here is the patch to vfprintf.c produced by diff -up.
>
> Cheers,
> Nicholas
>
Initially, we've added these changes to Newlib-1.11.0. They was tested with Newlib-1.11.0 too. But then I've copy changes to Newlib from CVS. vfprintf.c from CVS differs from Newlib-1.11.0's vfprintf.c. I didn't test (even compile) Newlib from CVS with these patch, but it must work.


Thanks.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]