Changeset 29e7cc7 in mainline for common/stdc/wchar.c
- Timestamp:
- 2025-04-18T15:14:10Z (8 months ago)
- Children:
- e77c3ed
- Parents:
- 800d188 (diff), 25fdb2d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
common/stdc/wchar.c (moved) (moved from kernel/generic/include/putchar.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
common/stdc/wchar.c
r800d188 r29e7cc7 1 1 /* 2 * Copyright (c) 20 01-2004 Jakub Jermar2 * Copyright (c) 2025 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kernel_generic 30 * @{ 31 */ 32 /** @file 33 */ 29 #include <uchar.h> 30 #include <wchar.h> 34 31 35 #ifndef KERN_PUTCHAR_H_ 36 #define KERN_PUTCHAR_H_ 37 38 #include <uchar.h> 39 40 extern void putuchar(char32_t); 41 32 #if __STDC_HOSTED__ 33 #include <fibril.h> 42 34 #endif 43 35 44 /** @} 45 */ 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->state == 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 }
Note:
See TracChangeset
for help on using the changeset viewer.
