[haiku-commits] haiku: hrev54163 - headers/posix

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 9 May 2020 15:29:32 -0400 (EDT)

hrev54163 adds 1 changeset to branch 'master'
old head: 566914fad4e1fdce4923bb0b2dc5bcf278232c0b
new head: 22337d8f4b959b3b6bdeda06be4b1b2eeb5dc874
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=22337d8f4b95+%5E566914fad4e1

----------------------------------------------------------------------------

22337d8f4b95: uchar.h: char16_t must be uint_least16_t
  
  We attempted to make it a 32bit char type, but that is actually not allowed
  unless we also make uint_least16_t a 32bit type. And even then, we
  wouldn't be allowed to store or handle values wider than 16bit.
  
  Comply more closely to the standard. As a result, mbtoc16r is not
  implemented. c16rtomb is implemented by casting the char to 32bit, which
  isn't really correct either (I think you're supposed to be able to feed
  the two halves of a > 16bit codepoint in two separate calls and get a
  meaningful result out?)
  
  Related to #15990 but we may want an actual implementation?
  
  Change-Id: If8198675c27dd2aa412bc44d12d3df4e31d3e8c7
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2623
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54163
Commit:      22337d8f4b959b3b6bdeda06be4b1b2eeb5dc874
URL:         https://git.haiku-os.org/haiku/commit/?id=22337d8f4b95
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sat May  9 11:11:45 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May  9 19:29:28 2020 UTC

Ticket:      https://dev.haiku-os.org/ticket/15990

----------------------------------------------------------------------------

1 file changed, 26 insertions(+), 11 deletions(-)
headers/posix/uchar.h | 37 ++++++++++++++++++++++++++-----------

----------------------------------------------------------------------------

diff --git a/headers/posix/uchar.h b/headers/posix/uchar.h
index 72f3ac18cd..8b090cba5e 100644
--- a/headers/posix/uchar.h
+++ b/headers/posix/uchar.h
@@ -1,44 +1,59 @@
 /*
- * Copyright 2018 Haiku, Inc. All Right Reserved
+ * Copyright 2018-2020 Haiku, Inc. All Right Reserved
  * Distributed under the terms of MIT license.
  */
 #ifndef _UCHAR_H
 #define _UCHAR_H
 
+
 #include <wchar.h>
 
+
 #ifdef __cplusplus
 extern "C" {
-#else
-typedef wchar_t char32_t; /* our wchar_t is utf32 */
-typedef wchar_t char16_t;
 #endif
 
+
+typedef uint_least32_t char32_t;
+typedef uint_least16_t char16_t;
+
+
 #define __STD_UTF_32__ 1
+#define __STD_UTF_16__ 1
+
+
+// TODO implement mbrtoc16
+
 
-/* We don't define __STD_UTF_16__, so the format of char16_t is unspecified */
 static __inline size_t
-c16rtomb(char *dest, char16_t wc, mbstate_t *mbState)
+c16rtomb(char *dest, char32_t wc, mbstate_t *mbState)
 {
-       return wcrtomb(dest, wc, mbState);
+       wchar_t tmp = (wchar_t)wc;
+       return wcrtomb(dest, tmp, mbState);
 }
+
+
 static __inline size_t
-mbrtoc16(char16_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
+mbrtoc32(char32_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
 {
-       return mbrtowc(dest, src, srcLength, mbState);
+       return mbrtowc((wchar_t*)dest, src, srcLength, mbState);
 }
 
+
 static __inline size_t
 c32rtomb(char *dest, char32_t wc, mbstate_t *mbState)
 {
-       return wcrtomb(dest, wc, mbState);
+       return wcrtomb(dest, (wchar_t)wc, mbState);
 }
+
+
 static __inline size_t
 mbrtoc32(char32_t *dest, const char *src, size_t srcLength, mbstate_t *mbState)
 {
-       return mbrtowc(dest, src, srcLength, mbState);
+       return mbrtowc((wchar_t*)dest, src, srcLength, mbState);
 }
 
+
 #ifdef __cplusplus
 }
 #endif


Other related posts:

  • » [haiku-commits] haiku: hrev54163 - headers/posix - waddlesplash