mirror of https://github.com/adtools/clib2.git
Provide some more wide char functions.
This commit is contained in:
parent
bc621bed9c
commit
d1092099d0
|
@ -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 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 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 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);
|
||||
|
|
|
@ -402,6 +402,7 @@ C_LIB := \
|
|||
wchar_wcschr.o \
|
||||
wchar_wcscmp.o \
|
||||
wchar_wcscpy.o \
|
||||
wchar_wcscspn.o \
|
||||
wchar_wcsftime.o \
|
||||
wchar_wcslen.o \
|
||||
wchar_wcsncat.o \
|
||||
|
|
|
@ -40,6 +40,5 @@
|
|||
int
|
||||
mbsinit(const mbstate_t *ps)
|
||||
{
|
||||
/* ZZZ unimplemented */
|
||||
return(0);
|
||||
return !ps || !*(unsigned *)ps;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,12 @@
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
/* Implementation based on musl */
|
||||
|
||||
wchar_t *
|
||||
wcschr(const wchar_t *s, wchar_t c)
|
||||
{
|
||||
/* ZZZ unimplemented */
|
||||
return(NULL);
|
||||
if (!c) return (wchar_t *)s + wcslen(s);
|
||||
for (; *s && *s != c; s++);
|
||||
return *s ? (wchar_t *)s : 0;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||
{
|
||||
/* ZZZ unimplemented */
|
||||
return(0);
|
||||
for (; n && *s1==*s2 && *s1 && *s2; n--, s1++, s2++);
|
||||
return n ? *s1 - *s2 : 0;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,13 @@
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
/* Implementation based on musl */
|
||||
|
||||
wchar_t *
|
||||
wcsncpy(wchar_t *dest, const wchar_t *src, size_t n)
|
||||
{
|
||||
/* ZZZ unimplemented */
|
||||
return(NULL);
|
||||
wchar_t *a = dest;
|
||||
while (n && *src) n--, *dest++ = *src++;
|
||||
wmemset(dest, 0, n);
|
||||
return a;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue