[PATCH] Add uchar.h

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Add uchar.h

Dave Korn-6
Dave Korn wrote:
>
>  I've got a bit of a load on right now what with gcc back in stage1.

  However, as part of dealing with that I did try throwing together one of
these.  I wrote this from scratch based solely on reading n1040; it's
skeletal, but at least provides the two new unicode typedefs.  Want it?

winsup/cygwin/ChangeLog

        * include/uchar.h:  New file.

    cheers,
      DaveK

Index: winsup/cygwin/include/uchar.h
===================================================================
RCS file: winsup/cygwin/include/uchar.h
diff -N winsup/cygwin/include/uchar.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ winsup/cygwin/include/uchar.h 3 Apr 2009 13:03:52 -0000
@@ -0,0 +1,37 @@
+/* uchar.h - unicode character types
+
+   Copyright 2009 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _UCHAR_H
+#define _UCHAR_H
+
+/* Exact-width character types */
+
+typedef unsigned short char16_t;    /* Must match uint_least16_t */
+typedef unsigned long  char32_t;    /* Must match uint_least32_t */
+
+
+/* We do not define an encoding yet. */
+
+/* #undef __STDC_UTF_16__ */
+/* #undef __STDC_UTF_32__ */
+
+/* We do not provide the standard library functions yet. */
+
+/* size_t mbrtoc16(char16_t * restrict pc16, const char * restrict s,
+ size_t n, mbstate_t * restrict ps); */
+
+/* size_t c16rtomb(char * restrict s, char16_t c16, mbstate_t * restrict ps); */
+
+/* size_t mbrtoc32(char32_t * restrict pc32, const char * restrict s, size_t n,
+ mbstate_t * restrict ps); */
+
+/* size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps); */
+
+#endif /* _UCHAR_H */
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add uchar.h

Corinna Vinschen-2
On Apr  3 14:18, Dave Korn wrote:
> Dave Korn wrote:
> >
> >  I've got a bit of a load on right now what with gcc back in stage1.
>
>   However, as part of dealing with that I did try throwing together one of
> these.  I wrote this from scratch based solely on reading n1040; it's
> skeletal, but at least provides the two new unicode typedefs.  Want it?

Care to explain?

- What's n1040?

- I don't see these defines anywhere near POSIX-1.2008.


Corinna


--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add uchar.h

Dave Korn-6
Corinna Vinschen wrote:

> On Apr  3 14:18, Dave Korn wrote:
>> Dave Korn wrote:
>>>  I've got a bit of a load on right now what with gcc back in stage1.
>>   However, as part of dealing with that I did try throwing together one of
>> these.  I wrote this from scratch based solely on reading n1040; it's
>> skeletal, but at least provides the two new unicode typedefs.  Want it?
>
> Care to explain?
>
> - What's n1040?

  An extension to the language standard specified by the ISO/IEC
JTC1/SC22/WG14 working group for the C language and targeted for the
forthcoming C1X update.

http://www.open-std.org/jtc1/sc22/WG14/

and specifically

http://www.open-std.org/jtc1/sc22/WG14/www/projects#19769

TR 19769: New character types in C

WG14 is working on a TR on new character types, including support for UTF-16.
The title is: TR 19769 - Extensions for the programming language C to support
new character data types. The latest draft, approved for publication, is in
document N1040.

    cheers,
      DaveK

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add uchar.h

Corinna Vinschen-2
On Apr  3 23:49, Dave Korn wrote:

> Corinna Vinschen wrote:
> > On Apr  3 14:18, Dave Korn wrote:
> >> Dave Korn wrote:
> >>>  I've got a bit of a load on right now what with gcc back in stage1.
> >>   However, as part of dealing with that I did try throwing together one of
> >> these.  I wrote this from scratch based solely on reading n1040; it's
> >> skeletal, but at least provides the two new unicode typedefs.  Want it?
> >
> > Care to explain?
> >
> > - What's n1040?
>
>   An extension to the language standard specified by the ISO/IEC
> JTC1/SC22/WG14 working group for the C language and targeted for the
> forthcoming C1X update.
>
> http://www.open-std.org/jtc1/sc22/WG14/
>
> and specifically
>
> http://www.open-std.org/jtc1/sc22/WG14/www/projects#19769
>
> TR 19769: New character types in C
>
> WG14 is working on a TR on new character types, including support for UTF-16.
> The title is: TR 19769 - Extensions for the programming language C to support
> new character data types. The latest draft, approved for publication, is in
> document N1040.

Thank you, I read it now.  Apart from thinking that it's a tad bit early
to introduce this header, I also think this would better fit into
newlib.  Btw, the functionality is quite easy to hack.  If this actually
becomes a standard, we can very quickly introduce the header *and* the
implementation.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add uchar.h

Dave Korn-6
Corinna Vinschen wrote:
> On Apr  3 23:49, Dave Korn wrote:

>> http://www.open-std.org/jtc1/sc22/WG14/www/projects#19769
>>
>> TR 19769: New character types in C

> Thank you, I read it now.  Apart from thinking that it's a tad bit early
> to introduce this header,

  I thought so too, but since there's a draft spec, and since there are
starting to spring up autoconf checks for this header, I didn't see why not to
offer it.

> I also think this would better fit into newlib.

  I'm not sure.  My reasoning was that since we override newlib's types system
by providing our own stdint.h, it made sense to provide our own uchar.h as well.

> Btw, the functionality is quite easy to hack.  If this actually
> becomes a standard, we can very quickly introduce the header *and* the
> implementation.

  Heh, I didn't even read the function descriptions, I literally just skimmed
the document and blindly copypasta'd the prototypes.

    cheers,
      DaveK
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add uchar.h

Corinna Vinschen-2
On Apr  4 13:28, Dave Korn wrote:
> Corinna Vinschen wrote:
> > I also think this would better fit into newlib.
>
>   I'm not sure.  My reasoning was that since we override newlib's types system
> by providing our own stdint.h, it made sense to provide our own uchar.h as well.

When I first wrote stdint.h for Cygwin, newlib hadn't one.  At the time
I didn't feel comfortable to write a header which fits the need of all
targets.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat