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: Adding mbstate_t, mbsinit(), mbrtowc(), mbrlen() etc.


On Thu, 2002-08-22 at 13:50, egor duda wrote:
> Hi!
> 
>   I'm preparing a patch to add restartable versions of multibyte
> conversion functions to newlib. As long as all state information is
> already handled by *_r() versions, this functions are just simple
> wrappers around foo() of foo_r() functions, depending on MB_CAPABLE.
> 
This is funny timing... I'm going to commit a (likely) very similar
patch today.
  
> I have a couple of questions, though. First, SUSv2 states that
> multibyte handling functions are declared in wchar.h, whereas newlib
> currently declares them in stdlib.h. Should we create wchar.h and move
> all appropriate stuff there?
>
Yes, my patch does add a wchar.h header.  Currently it only declares the
extra multibyte handling functions I've added, but we should definitely
look into moving the other mb declarations there from stdlib.h.  
 
> Second, currently state is simple 0/1 switch, so now it's enough to have
> typedef int mbstate_t;
> But if in the future someone will want to add new encodings which
> require more sophisticated state information (i don't know if such
> encodings actually exist), we'll be forced to change definition of
> mbstate_t thus breaking backward compatibility. GLIBC defines
> mbstate_t as struct { int; union { wchar_t; char[4] }}, while
> Microsoft's C runtime defines it as int. Would 'int' be enough for
> everything? 
> 

Yes my patch declares an mbstate_t type that is the same as glibc's, and
converts all the existing functions to use it.

Let me know if there's something else you need once the patch is checked
in.

Thanks,
Tom

> egor.            mailto:deo@logos-m.ru icq 5165414 fidonet 2:5020/496.19
> 
-- 
Thomas Fitzsimmons
Red Hat Canada Limited        e-mail: fitzsim@redhat.com
2323 Yonge Street, Suite 300
Toronto, ON M4P2C9


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