Changeset 696b405 in mainline
- Timestamp:
- 2025-04-13T12:54:10Z (5 days ago)
- Branches:
- master
- Children:
- 9daee3de
- Parents:
- 7d1497c
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-13 10:13:16)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-13 12:54:10)
- Files:
-
- 3 added
- 3 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
abi/include/_bits/mbstate_t.h
r7d1497c r696b405 1 1 /* 2 * Copyright (c) 202 0 Martin Decky2 * Copyright (c) 2025 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kernel_generic29 /** @addtogroup bits 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef _ KERN_UCHAR_H_36 #define _ KERN_UCHAR_H_35 #ifndef _BITS_MBSTATE_T_H_ 36 #define _BITS_MBSTATE_T_H_ 37 37 38 #include <_bits/uchar.h> 38 typedef struct { 39 unsigned short continuation; 40 } mbstate_t; 39 41 40 42 #endif -
abi/include/_bits/uchar.h
r7d1497c r696b405 46 46 #endif 47 47 48 typedef uint32_t char32_t; 48 typedef uint_least16_t char16_t; 49 typedef uint_least32_t char32_t; 49 50 50 51 #endif -
common/include/uchar.h
r7d1497c r696b405 1 1 /* 2 * Copyright (c) 202 0 Martin Decky2 * Copyright (c) 2025 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 36 36 #define _LIBC_UCHAR_H_ 37 37 38 #include <_bits/mbstate_t.h> 39 #include <_bits/size_t.h> 38 40 #include <_bits/uchar.h> 41 #include <stdint.h> 42 43 size_t mbrtoc8(char8_t *__restrict pc8, const char *__restrict s, size_t n, 44 mbstate_t *__restrict ps); 45 size_t c8rtomb(char *__restrict s, char8_t c8, mbstate_t *__restrict ps); 46 size_t mbrtoc16(char16_t *__restrict pc16, const char *__restrict s, size_t n, 47 mbstate_t *__restrict ps); 48 size_t c16rtomb(char *__restrict s, char16_t c16, mbstate_t *__restrict ps); 49 size_t mbrtoc32(char32_t *__restrict pc32, const char *__restrict s, size_t n, 50 mbstate_t *__restrict ps); 51 size_t c32rtomb(char *__restrict s, char32_t c32, mbstate_t *__restrict ps); 52 53 #ifdef _HELENOS_SOURCE 54 #define UCHAR_ILSEQ ((size_t) -1) 55 #define UCHAR_INCOMPLETE ((size_t) -2) 56 #define UCHAR_CONTINUED ((size_t) -3) 57 #endif 39 58 40 59 #endif -
common/stdc/wchar.c
r7d1497c r696b405 1 1 /* 2 * Copyright (c) 20 17 CZ.NIC, z.s.p.o.2 * Copyright (c) 2025 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /* 30 * Authors: 31 * Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com> 32 */ 29 #include <uchar.h> 30 #include <wchar.h> 33 31 34 /** @addtogroup libc 35 * @{ 36 */ 37 /** @file 38 */ 39 40 #ifndef _LIBC_WCHAR_H_ 41 #define _LIBC_WCHAR_H_ 42 43 #include <_bits/size_t.h> 44 #include <_bits/wchar_t.h> 45 #include <_bits/wchar_limits.h> 46 #include <_bits/wint_t.h> 47 #include <_bits/NULL.h> 48 #include <_bits/WEOF.h> 49 32 #if __STDC_HOSTED__ 33 #include <fibril.h> 50 34 #endif 51 35 52 /** @} 53 */ 36 wint_t btowc(int c) 37 { 38 return (c < 0x80) ? c : WEOF; 39 } 40 41 int wctob(wint_t c) 42 { 43 return c; 44 } 45 46 int mbsinit(const mbstate_t *ps) 47 { 48 return ps == NULL || ps->continuation == 0; 49 } 50 51 size_t mbrlen(const char *s, size_t n, mbstate_t *ps) 52 { 53 #if __STDC_HOSTED__ 54 static fibril_local mbstate_t global_state; 55 if (!ps) 56 ps = &global_state; 57 #endif 58 59 return mbrtowc(NULL, s, n, ps); 60 } 61 62 _Static_assert(sizeof(wchar_t) == sizeof(char16_t) || sizeof(wchar_t) == sizeof(char32_t)); 63 64 size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) 65 { 66 #if __STDC_HOSTED__ 67 static fibril_local mbstate_t global_state; 68 if (!ps) 69 ps = &global_state; 70 #endif 71 72 if (sizeof(wchar_t) == sizeof(char16_t)) 73 return mbrtoc16((char16_t *) pwc, s, n, ps); 74 else 75 return mbrtoc32((char32_t *) pwc, s, n, ps); 76 } 77 78 size_t wcrtomb(char *s, wchar_t wc, mbstate_t * ps) 79 { 80 #if __STDC_HOSTED__ 81 static fibril_local mbstate_t global_state; 82 if (!ps) 83 ps = &global_state; 84 #endif 85 86 if (sizeof(wchar_t) == sizeof(char16_t)) 87 return c16rtomb(s, (char16_t) wc, ps); 88 else 89 return c32rtomb(s, (char32_t) wc, ps); 90 } -
uspace/lib/c/meson.build
r7d1497c r696b405 71 71 'common/stdc/qsort.c', 72 72 'common/stdc/calloc.c', 73 'common/stdc/uchar.c', 74 'common/stdc/wchar.c', 73 75 'common/gsort.c', 74 76 'common/str.c', … … 196 198 'test/string.c', 197 199 'test/strtol.c', 200 'test/uchar.c', 198 201 'test/uuid.c', 199 202 ) -
uspace/lib/c/test/main.c
r7d1497c r696b405 57 57 PCUT_IMPORT(strtol); 58 58 PCUT_IMPORT(table); 59 PCUT_IMPORT(uchar); 59 60 PCUT_IMPORT(uuid); 60 61
Note:
See TracChangeset
for help on using the changeset viewer.