mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Provide some more wide char functions.
This commit is contained in:
@ -192,7 +192,7 @@ extern size_t mbsrtowcs(wchar_t *restrict dst, const char **restrict src, size_t
|
|||||||
extern size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps);
|
extern size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps);
|
||||||
extern int wcscoll(const wchar_t *ws1, const wchar_t *ws2);
|
extern int wcscoll(const wchar_t *ws1, const wchar_t *ws2);
|
||||||
extern int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t loc);
|
extern int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t loc);
|
||||||
extern size_t wcscspn(const wchar_t *ws1, const wchar_t *ws2);
|
extern size_t wcscspn(const wchar_t *s, const wchar_t *c);
|
||||||
extern size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict src, size_t nwc, size_t len, mbstate_t *restrict ps);
|
extern size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict src, size_t nwc, size_t len, mbstate_t *restrict ps);
|
||||||
extern wchar_t * wcsrchr(const wchar_t *ws, wchar_t wc);
|
extern wchar_t * wcsrchr(const wchar_t *ws, wchar_t wc);
|
||||||
extern size_t wcsrtombs(char *restrict dst, const wchar_t **restrict src, size_t len, mbstate_t *restrict ps);
|
extern size_t wcsrtombs(char *restrict dst, const wchar_t **restrict src, size_t len, mbstate_t *restrict ps);
|
||||||
|
|||||||
@ -402,6 +402,7 @@ C_LIB := \
|
|||||||
wchar_wcschr.o \
|
wchar_wcschr.o \
|
||||||
wchar_wcscmp.o \
|
wchar_wcscmp.o \
|
||||||
wchar_wcscpy.o \
|
wchar_wcscpy.o \
|
||||||
|
wchar_wcscspn.o \
|
||||||
wchar_wcsftime.o \
|
wchar_wcsftime.o \
|
||||||
wchar_wcslen.o \
|
wchar_wcslen.o \
|
||||||
wchar_wcsncat.o \
|
wchar_wcsncat.o \
|
||||||
|
|||||||
@ -40,6 +40,5 @@
|
|||||||
int
|
int
|
||||||
mbsinit(const mbstate_t *ps)
|
mbsinit(const mbstate_t *ps)
|
||||||
{
|
{
|
||||||
/* ZZZ unimplemented */
|
return !ps || !*(unsigned *)ps;
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,9 +37,12 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* Implementation based on musl */
|
||||||
|
|
||||||
wchar_t *
|
wchar_t *
|
||||||
wcschr(const wchar_t *s, wchar_t c)
|
wcschr(const wchar_t *s, wchar_t c)
|
||||||
{
|
{
|
||||||
/* ZZZ unimplemented */
|
if (!c) return (wchar_t *)s + wcslen(s);
|
||||||
return(NULL);
|
for (; *s && *s != c; s++);
|
||||||
|
return *s ? (wchar_t *)s : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
50
library/wchar_wcscspn.c
Normal file
50
library/wchar_wcscspn.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* $Id: wchar_wcsspn.c,v 1.3 2006-01-08 12:04:27 obarthel Exp $
|
||||||
|
*
|
||||||
|
* :ts=4
|
||||||
|
*
|
||||||
|
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||||
|
* Copyright (c) 2002-2015 by Olaf Barthel <obarthel (at) gmx.net>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _WCHAR_HEADERS_H
|
||||||
|
#include "wchar_headers.h"
|
||||||
|
#endif /* _WCHAR_HEADERS_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* Implementation based on musl */
|
||||||
|
|
||||||
|
size_t
|
||||||
|
wcscspn(const wchar_t *s, const wchar_t *c)
|
||||||
|
{
|
||||||
|
const wchar_t *a;
|
||||||
|
if (!c[0]) return wcslen(s);
|
||||||
|
if (!c[1]) return (s=wcschr(a=s, *c)) ? (size_t)(s-a) : wcslen(a);
|
||||||
|
for (a=s; *s && !wcschr(c, *s); s++);
|
||||||
|
return s-a;
|
||||||
|
}
|
||||||
@ -37,9 +37,11 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* Implementation based on musl */
|
||||||
|
|
||||||
int
|
int
|
||||||
wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||||
{
|
{
|
||||||
/* ZZZ unimplemented */
|
for (; n && *s1==*s2 && *s1 && *s2; n--, s1++, s2++);
|
||||||
return(0);
|
return n ? *s1 - *s2 : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,9 +37,13 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* Implementation based on musl */
|
||||||
|
|
||||||
wchar_t *
|
wchar_t *
|
||||||
wcsncpy(wchar_t *dest, const wchar_t *src, size_t n)
|
wcsncpy(wchar_t *dest, const wchar_t *src, size_t n)
|
||||||
{
|
{
|
||||||
/* ZZZ unimplemented */
|
wchar_t *a = dest;
|
||||||
return(NULL);
|
while (n && *src) n--, *dest++ = *src++;
|
||||||
|
wmemset(dest, 0, n);
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user