diff options
author | espie <> | 2005-04-13 16:35:58 +0000 |
---|---|---|
committer | espie <> | 2005-04-13 16:35:58 +0000 |
commit | 5bfe57853dc600a767e768df6a37a54f5e5d2d96 (patch) | |
tree | 15608546e979870c217ffccdd08111c6a92073c5 /src | |
parent | 9a562e7f867aa1e065d1e4d9cc4f1807e59add2f (diff) | |
download | openbsd-5bfe57853dc600a767e768df6a37a54f5e5d2d96.tar.gz openbsd-5bfe57853dc600a767e768df6a37a54f5e5d2d96.tar.bz2 openbsd-5bfe57853dc600a767e768df6a37a54f5e5d2d96.zip |
Import w* functions so that I can send smaller diffs around.
(Nothing activated yet, of course)
okay deraadt@
Diffstat (limited to 'src')
25 files changed, 1592 insertions, 0 deletions
diff --git a/src/lib/libc/string/wcscat.c b/src/lib/libc/string/wcscat.c new file mode 100644 index 0000000000..69c8c0c251 --- /dev/null +++ b/src/lib/libc/string/wcscat.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* $OpenBSD: wcscat.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcscat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcscat.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcscat(s1, s2) | ||
40 | wchar_t *s1; | ||
41 | const wchar_t *s2; | ||
42 | { | ||
43 | wchar_t *p; | ||
44 | wchar_t *q; | ||
45 | const wchar_t *r; | ||
46 | |||
47 | p = s1; | ||
48 | while (*p) | ||
49 | p++; | ||
50 | q = p; | ||
51 | r = s2; | ||
52 | while (*r) | ||
53 | *q++ = *r++; | ||
54 | *q = '\0'; | ||
55 | return s1; | ||
56 | } | ||
diff --git a/src/lib/libc/string/wcschr.c b/src/lib/libc/string/wcschr.c new file mode 100644 index 0000000000..eb4e65a85d --- /dev/null +++ b/src/lib/libc/string/wcschr.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* $OpenBSD: wcschr.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcschr.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcschr.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcschr(s, c) | ||
40 | const wchar_t *s; | ||
41 | wchar_t c; | ||
42 | { | ||
43 | const wchar_t *p; | ||
44 | |||
45 | p = s; | ||
46 | while (*p) { | ||
47 | if (*p == c) { | ||
48 | /* LINTED interface specification */ | ||
49 | return (wchar_t *)p; | ||
50 | } | ||
51 | p++; | ||
52 | } | ||
53 | return NULL; | ||
54 | } | ||
diff --git a/src/lib/libc/string/wcscmp.c b/src/lib/libc/string/wcscmp.c new file mode 100644 index 0000000000..0f0dc0efdf --- /dev/null +++ b/src/lib/libc/string/wcscmp.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* $OpenBSD: wcscmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcscmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1990, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * This code is derived from software contributed to Berkeley by | ||
9 | * Chris Torek. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer. | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in the | ||
18 | * documentation and/or other materials provided with the distribution. | ||
19 | * 3. Neither the name of the University nor the names of its contributors | ||
20 | * may be used to endorse or promote products derived from this software | ||
21 | * without specific prior written permission. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | * SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | #if defined(LIBC_SCCS) && !defined(lint) | ||
37 | static char *rcsid = "$OpenBSD: wcscmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
38 | #endif /* LIBC_SCCS and not lint */ | ||
39 | |||
40 | #include <wchar.h> | ||
41 | #include "locale/runetype.h" | ||
42 | |||
43 | /* | ||
44 | * Compare strings. | ||
45 | */ | ||
46 | int | ||
47 | wcscmp(s1, s2) | ||
48 | const wchar_t *s1, *s2; | ||
49 | { | ||
50 | |||
51 | while (*s1 == *s2++) | ||
52 | if (*s1++ == 0) | ||
53 | return (0); | ||
54 | /* XXX assumes wchar_t = int */ | ||
55 | return (*(const __nbrune_t *)s1 - *(const __nbrune_t *)--s2); | ||
56 | } | ||
diff --git a/src/lib/libc/string/wcscpy.c b/src/lib/libc/string/wcscpy.c new file mode 100644 index 0000000000..22f5bcbc7d --- /dev/null +++ b/src/lib/libc/string/wcscpy.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* $OpenBSD: wcscpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcscpy.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcscpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcscpy(s1, s2) | ||
40 | wchar_t *s1; | ||
41 | const wchar_t *s2; | ||
42 | { | ||
43 | wchar_t *p; | ||
44 | const wchar_t *q; | ||
45 | |||
46 | *s1 = '\0'; | ||
47 | p = s1; | ||
48 | q = s2; | ||
49 | while (*q) | ||
50 | *p++ = *q++; | ||
51 | *p = '\0'; | ||
52 | |||
53 | return s1; | ||
54 | } | ||
diff --git a/src/lib/libc/string/wcscspn.c b/src/lib/libc/string/wcscspn.c new file mode 100644 index 0000000000..905c937695 --- /dev/null +++ b/src/lib/libc/string/wcscspn.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: wcscspn.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcscspn.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | size_t | ||
39 | wcscspn(s, set) | ||
40 | const wchar_t *s; | ||
41 | const wchar_t *set; | ||
42 | { | ||
43 | const wchar_t *p; | ||
44 | const wchar_t *q; | ||
45 | |||
46 | p = s; | ||
47 | while (*p) { | ||
48 | q = set; | ||
49 | while (*q) { | ||
50 | if (*p == *q) | ||
51 | goto done; | ||
52 | q++; | ||
53 | } | ||
54 | p++; | ||
55 | } | ||
56 | |||
57 | done: | ||
58 | return (p - s); | ||
59 | } | ||
diff --git a/src/lib/libc/string/wcslcat.c b/src/lib/libc/string/wcslcat.c new file mode 100644 index 0000000000..266d012ad4 --- /dev/null +++ b/src/lib/libc/string/wcslcat.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* $OpenBSD: wcslcat.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */ | ||
3 | /* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */ | ||
4 | |||
5 | /* | ||
6 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. The name of the author may not be used to endorse or promote products | ||
18 | * derived from this software without specific prior written permission. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
22 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
23 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
26 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
28 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
29 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcslcat.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <sys/types.h> | ||
37 | #include <wchar.h> | ||
38 | |||
39 | /* | ||
40 | * Appends src to string dst of size siz (unlike wcsncat, siz is the | ||
41 | * full size of dst, not space left). At most siz-1 characters | ||
42 | * will be copied. Always NUL terminates (unless siz == 0). | ||
43 | * Returns wcslen(initial dst) + wcslen(src); if retval >= siz, | ||
44 | * truncation occurred. | ||
45 | */ | ||
46 | size_t | ||
47 | wcslcat(dst, src, siz) | ||
48 | wchar_t *dst; | ||
49 | const wchar_t *src; | ||
50 | size_t siz; | ||
51 | { | ||
52 | wchar_t *d = dst; | ||
53 | const wchar_t *s = src; | ||
54 | size_t n = siz; | ||
55 | size_t dlen; | ||
56 | |||
57 | /* Find the end of dst and adjust bytes left but don't go past end */ | ||
58 | while (*d != '\0' && n-- != 0) | ||
59 | d++; | ||
60 | dlen = d - dst; | ||
61 | n = siz - dlen; | ||
62 | |||
63 | if (n == 0) | ||
64 | return(dlen + wcslen(s)); | ||
65 | while (*s != '\0') { | ||
66 | if (n != 1) { | ||
67 | *d++ = *s; | ||
68 | n--; | ||
69 | } | ||
70 | s++; | ||
71 | } | ||
72 | *d = '\0'; | ||
73 | |||
74 | return(dlen + (s - src)); /* count does not include NUL */ | ||
75 | } | ||
diff --git a/src/lib/libc/string/wcslcpy.c b/src/lib/libc/string/wcslcpy.c new file mode 100644 index 0000000000..101161e9ce --- /dev/null +++ b/src/lib/libc/string/wcslcpy.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* $OpenBSD: wcslcpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */ | ||
3 | /* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */ | ||
4 | |||
5 | /* | ||
6 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | ||
7 | * All rights reserved. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. The name of the author may not be used to endorse or promote products | ||
18 | * derived from this software without specific prior written permission. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
22 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
23 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
26 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
28 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
29 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcslcpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <sys/types.h> | ||
37 | #include <wchar.h> | ||
38 | |||
39 | /* | ||
40 | * Copy src to string dst of size siz. At most siz-1 characters | ||
41 | * will be copied. Always NUL terminates (unless siz == 0). | ||
42 | * Returns wcslen(src); if retval >= siz, truncation occurred. | ||
43 | */ | ||
44 | size_t | ||
45 | wcslcpy(dst, src, siz) | ||
46 | wchar_t *dst; | ||
47 | const wchar_t *src; | ||
48 | size_t siz; | ||
49 | { | ||
50 | wchar_t *d = dst; | ||
51 | const wchar_t *s = src; | ||
52 | size_t n = siz; | ||
53 | |||
54 | /* Copy as many bytes as will fit */ | ||
55 | if (n != 0 && --n != 0) { | ||
56 | do { | ||
57 | if ((*d++ = *s++) == 0) | ||
58 | break; | ||
59 | } while (--n != 0); | ||
60 | } | ||
61 | |||
62 | /* Not enough room in dst, add NUL and traverse rest of src */ | ||
63 | if (n == 0) { | ||
64 | if (siz != 0) | ||
65 | *d = '\0'; /* NUL-terminate dst */ | ||
66 | while (*s++) | ||
67 | ; | ||
68 | } | ||
69 | |||
70 | return(s - src - 1); /* count does not include NUL */ | ||
71 | } | ||
diff --git a/src/lib/libc/string/wcslen.c b/src/lib/libc/string/wcslen.c new file mode 100644 index 0000000000..6d1c5e5f30 --- /dev/null +++ b/src/lib/libc/string/wcslen.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* $OpenBSD: wcslen.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcslen.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | size_t | ||
39 | wcslen(s) | ||
40 | const wchar_t *s; | ||
41 | { | ||
42 | const wchar_t *p; | ||
43 | |||
44 | p = s; | ||
45 | while (*p) | ||
46 | p++; | ||
47 | |||
48 | return p - s; | ||
49 | } | ||
diff --git a/src/lib/libc/string/wcsncat.c b/src/lib/libc/string/wcsncat.c new file mode 100644 index 0000000000..984ef4cabb --- /dev/null +++ b/src/lib/libc/string/wcsncat.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: wcsncat.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcsncat.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcsncat(s1, s2, n) | ||
40 | wchar_t *s1; | ||
41 | const wchar_t *s2; | ||
42 | size_t n; | ||
43 | { | ||
44 | wchar_t *p; | ||
45 | wchar_t *q; | ||
46 | const wchar_t *r; | ||
47 | |||
48 | p = s1; | ||
49 | while (*p) | ||
50 | p++; | ||
51 | q = p; | ||
52 | r = s2; | ||
53 | while (*r && n) { | ||
54 | *q++ = *r++; | ||
55 | n--; | ||
56 | } | ||
57 | *q = '\0'; | ||
58 | return s1; | ||
59 | } | ||
diff --git a/src/lib/libc/string/wcsncmp.c b/src/lib/libc/string/wcsncmp.c new file mode 100644 index 0000000000..e89b7914d1 --- /dev/null +++ b/src/lib/libc/string/wcsncmp.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* $OpenBSD: wcsncmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsncmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ | ||
3 | |||
4 | /* | ||
5 | * Copyright (c) 1989, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the name of the University nor the names of its contributors | ||
17 | * may be used to endorse or promote products derived from this software | ||
18 | * without specific prior written permission. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | * SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | #if defined(LIBC_SCCS) && !defined(lint) | ||
34 | static char *rcsid = "$OpenBSD: wcsncmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
35 | #endif /* LIBC_SCCS and not lint */ | ||
36 | |||
37 | #include <wchar.h> | ||
38 | #include "locale/runetype.h" | ||
39 | |||
40 | int | ||
41 | wcsncmp(s1, s2, n) | ||
42 | const wchar_t *s1, *s2; | ||
43 | size_t n; | ||
44 | { | ||
45 | |||
46 | if (n == 0) | ||
47 | return (0); | ||
48 | do { | ||
49 | if (*s1 != *s2++) { | ||
50 | /* XXX assumes wchar_t = int */ | ||
51 | return (*(const __nbrune_t *)s1 - | ||
52 | *(const __nbrune_t *)--s2); | ||
53 | } | ||
54 | if (*s1++ == 0) | ||
55 | break; | ||
56 | } while (--n != 0); | ||
57 | return (0); | ||
58 | } | ||
diff --git a/src/lib/libc/string/wcsncpy.c b/src/lib/libc/string/wcsncpy.c new file mode 100644 index 0000000000..aa7bf95919 --- /dev/null +++ b/src/lib/libc/string/wcsncpy.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* $OpenBSD: wcsncpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsncpy.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcsncpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcsncpy(s1, s2, n) | ||
40 | wchar_t *s1; | ||
41 | const wchar_t *s2; | ||
42 | size_t n; | ||
43 | { | ||
44 | wchar_t *p; | ||
45 | const wchar_t *q; | ||
46 | |||
47 | *s1 = '\0'; | ||
48 | p = s1; | ||
49 | q = s2; | ||
50 | while (n && *q) { | ||
51 | *p++ = *q++; | ||
52 | n--; | ||
53 | } | ||
54 | *p = '\0'; | ||
55 | |||
56 | return s1; | ||
57 | } | ||
diff --git a/src/lib/libc/string/wcspbrk.c b/src/lib/libc/string/wcspbrk.c new file mode 100644 index 0000000000..aeaac6ced4 --- /dev/null +++ b/src/lib/libc/string/wcspbrk.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: wcspbrk.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcspbrk.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcspbrk.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcspbrk(s, set) | ||
40 | const wchar_t *s; | ||
41 | const wchar_t *set; | ||
42 | { | ||
43 | const wchar_t *p; | ||
44 | const wchar_t *q; | ||
45 | |||
46 | p = s; | ||
47 | while (*p) { | ||
48 | q = set; | ||
49 | while (*q) { | ||
50 | if (*p == *q) { | ||
51 | /* LINTED interface specification */ | ||
52 | return (wchar_t *)p; | ||
53 | } | ||
54 | q++; | ||
55 | } | ||
56 | p++; | ||
57 | } | ||
58 | return NULL; | ||
59 | } | ||
diff --git a/src/lib/libc/string/wcsrchr.c b/src/lib/libc/string/wcsrchr.c new file mode 100644 index 0000000000..d0cd8aebb4 --- /dev/null +++ b/src/lib/libc/string/wcsrchr.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* $OpenBSD: wcsrchr.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsrchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcsrchr.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wcsrchr(s, c) | ||
40 | const wchar_t *s; | ||
41 | wchar_t c; | ||
42 | { | ||
43 | const wchar_t *p; | ||
44 | |||
45 | p = s; | ||
46 | while (*p) | ||
47 | p++; | ||
48 | while (s <= p) { | ||
49 | if (*p == c) { | ||
50 | /* LINTED interface specification */ | ||
51 | return (wchar_t *)p; | ||
52 | } | ||
53 | p--; | ||
54 | } | ||
55 | return NULL; | ||
56 | } | ||
diff --git a/src/lib/libc/string/wcsspn.c b/src/lib/libc/string/wcsspn.c new file mode 100644 index 0000000000..52b22e3d3b --- /dev/null +++ b/src/lib/libc/string/wcsspn.c | |||
@@ -0,0 +1,61 @@ | |||
1 | /* $OpenBSD: wcsspn.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999,2001 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * $Citrus: xpg4dl/FreeBSD/lib/libc/string/wcsspn.c,v 1.3 2001/09/21 16:06:43 yamt Exp $ | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcsspn.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | size_t | ||
39 | wcsspn(s, set) | ||
40 | const wchar_t *s; | ||
41 | const wchar_t *set; | ||
42 | { | ||
43 | const wchar_t *p; | ||
44 | const wchar_t *q; | ||
45 | |||
46 | p = s; | ||
47 | while (*p) { | ||
48 | q = set; | ||
49 | while (*q) { | ||
50 | if (*p == *q) | ||
51 | break; | ||
52 | q++; | ||
53 | } | ||
54 | if (!*q) | ||
55 | goto done; | ||
56 | p++; | ||
57 | } | ||
58 | |||
59 | done: | ||
60 | return (p - s); | ||
61 | } | ||
diff --git a/src/lib/libc/string/wcsstr.c b/src/lib/libc/string/wcsstr.c new file mode 100644 index 0000000000..992b5cab0f --- /dev/null +++ b/src/lib/libc/string/wcsstr.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* $OpenBSD: wcsstr.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcsstr.c,v 1.3 2003/03/05 20:18:17 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsstr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcsstr.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | #ifdef WCSWCS | ||
40 | wcswcs(big, little) | ||
41 | #else | ||
42 | wcsstr(big, little) | ||
43 | #endif | ||
44 | const wchar_t *big; | ||
45 | const wchar_t *little; | ||
46 | { | ||
47 | const wchar_t *p; | ||
48 | const wchar_t *q; | ||
49 | const wchar_t *r; | ||
50 | |||
51 | if (!*little) { | ||
52 | /* LINTED interface specification */ | ||
53 | return (wchar_t *)big; | ||
54 | } | ||
55 | if (wcslen(big) < wcslen(little)) | ||
56 | return NULL; | ||
57 | |||
58 | p = big; | ||
59 | q = little; | ||
60 | while (*p) { | ||
61 | q = little; | ||
62 | r = p; | ||
63 | while (*q) { | ||
64 | if (*r != *q) | ||
65 | break; | ||
66 | q++; | ||
67 | r++; | ||
68 | } | ||
69 | if (!*q) { | ||
70 | /* LINTED interface specification */ | ||
71 | return (wchar_t *)p; | ||
72 | } | ||
73 | p++; | ||
74 | } | ||
75 | return NULL; | ||
76 | } | ||
diff --git a/src/lib/libc/string/wcstok.3 b/src/lib/libc/string/wcstok.3 new file mode 100644 index 0000000000..df10000af1 --- /dev/null +++ b/src/lib/libc/string/wcstok.3 | |||
@@ -0,0 +1,136 @@ | |||
1 | .\" $NetBSD: wcstok.3,v 1.3 2003/09/08 17:54:33 wiz Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1998 Softweyr LLC. All rights reserved. | ||
4 | .\" | ||
5 | .\" strtok_r, from Berkeley strtok | ||
6 | .\" Oct 13, 1998 by Wes Peters <wes@softweyr.com> | ||
7 | .\" | ||
8 | .\" Copyright (c) 1988, 1991, 1993 | ||
9 | .\" The Regents of the University of California. All rights reserved. | ||
10 | .\" | ||
11 | .\" This code is derived from software contributed to Berkeley by | ||
12 | .\" the American National Standards Committee X3, on Information | ||
13 | .\" Processing Systems. | ||
14 | .\" | ||
15 | .\" Redistribution and use in source and binary forms, with or without | ||
16 | .\" modification, are permitted provided that the following conditions | ||
17 | .\" are met: | ||
18 | .\" | ||
19 | .\" 1. Redistributions of source code must retain the above copyright | ||
20 | .\" notices, this list of conditions and the following disclaimer. | ||
21 | .\" | ||
22 | .\" 2. Redistributions in binary form must reproduce the above | ||
23 | .\" copyright notices, this list of conditions and the following | ||
24 | .\" disclaimer in the documentation and/or other materials provided | ||
25 | .\" with the distribution. | ||
26 | .\" | ||
27 | .\" 3. All advertising materials mentioning features or use of this | ||
28 | .\" software must display the following acknowledgement: | ||
29 | .\" | ||
30 | .\" This product includes software developed by Softweyr LLC, the | ||
31 | .\" University of California, Berkeley, and its contributors. | ||
32 | .\" | ||
33 | .\" 4. Neither the name of Softweyr LLC, the University nor the names | ||
34 | .\" of its contributors may be used to endorse or promote products | ||
35 | .\" derived from this software without specific prior written | ||
36 | .\" permission. | ||
37 | .\" | ||
38 | .\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND | ||
39 | .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
40 | .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
41 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
42 | .\" DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR | ||
43 | .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
45 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
46 | .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
47 | .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
48 | .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
49 | .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
50 | .\" SUCH DAMAGE. | ||
51 | .\" | ||
52 | .\" Original version ID: | ||
53 | .\" FreeBSD: src/lib/libc/string/wcstok.3,v 1.4 2002/10/15 09:49:54 tjr Exp | ||
54 | .\" | ||
55 | .Dd October 3, 2002 | ||
56 | .Dt WCSTOK 3 | ||
57 | .Os | ||
58 | .Sh NAME | ||
59 | .Nm wcstok | ||
60 | .Nd split wide-character string into tokens | ||
61 | .Sh LIBRARY | ||
62 | .Lb libc | ||
63 | .Sh SYNOPSIS | ||
64 | .In wchar.h | ||
65 | .Ft wchar_t * | ||
66 | .Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last" | ||
67 | .Sh DESCRIPTION | ||
68 | The | ||
69 | .Fn wcstok | ||
70 | function | ||
71 | is used to isolate sequential tokens in a null-terminated wide character | ||
72 | string, | ||
73 | .Fa str . | ||
74 | These tokens are separated in the string by at least one of the | ||
75 | characters in | ||
76 | .Fa sep . | ||
77 | The first time that | ||
78 | .Fn wcstok | ||
79 | is called, | ||
80 | .Fa str | ||
81 | should be specified; subsequent calls, wishing to obtain further tokens | ||
82 | from the same string, should pass a null pointer instead. | ||
83 | The separator string, | ||
84 | .Fa sep , | ||
85 | must be supplied each time, and may change between calls. | ||
86 | The context pointer | ||
87 | .Fa last | ||
88 | must be provided on each call. | ||
89 | .Pp | ||
90 | The | ||
91 | .Fn wcstok | ||
92 | function is the wide character counterpart of the | ||
93 | .Fn strtok_r | ||
94 | function. | ||
95 | .Sh RETURN VALUES | ||
96 | The | ||
97 | .Fn wcstok | ||
98 | function | ||
99 | returns a pointer to the beginning of each subsequent token in the string, | ||
100 | after replacing the token itself with a null wide character (L'\e0'). | ||
101 | When no more tokens remain, a null pointer is returned. | ||
102 | .Sh EXAMPLES | ||
103 | The following code fragment splits a wide character string on | ||
104 | .Tn ASCII | ||
105 | space, tab and newline characters and writes the tokens to | ||
106 | standard output: | ||
107 | .Bd -literal -offset indent | ||
108 | const wchar_t *seps = L" \et\en"; | ||
109 | wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree \en"; | ||
110 | |||
111 | for (tok = wcstok(text, seps, &last); tok != NULL; | ||
112 | tok = wcstok(NULL, seps, &last)) | ||
113 | wprintf(L"%ls\en", tok); | ||
114 | .Ed | ||
115 | .Sh COMPATIBILITY | ||
116 | Some early implementations of | ||
117 | .Fn wcstok | ||
118 | omit the | ||
119 | context pointer argument, | ||
120 | .Fa last , | ||
121 | and maintain state across calls in a static variable like | ||
122 | .Fn strtok | ||
123 | does. | ||
124 | .Sh SEE ALSO | ||
125 | .Xr strtok 3 , | ||
126 | .Xr wcschr 3 , | ||
127 | .Xr wcscspn 3 , | ||
128 | .Xr wcspbrk 3 , | ||
129 | .Xr wcsrchr 3 , | ||
130 | .Xr wcsspn 3 | ||
131 | .Sh STANDARDS | ||
132 | The | ||
133 | .Fn wcstok | ||
134 | function | ||
135 | conforms to | ||
136 | .St -isoC-99 . | ||
diff --git a/src/lib/libc/string/wcstok.c b/src/lib/libc/string/wcstok.c new file mode 100644 index 0000000000..1b0790fdc6 --- /dev/null +++ b/src/lib/libc/string/wcstok.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* $OpenBSD: wcstok.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1998 Softweyr LLC. All rights reserved. | ||
6 | * | ||
7 | * strtok_r, from Berkeley strtok | ||
8 | * Oct 13, 1998 by Wes Peters <wes@softweyr.com> | ||
9 | * | ||
10 | * Copyright (c) 1988, 1993 | ||
11 | * The Regents of the University of California. All rights reserved. | ||
12 | * | ||
13 | * Redistribution and use in source and binary forms, with or without | ||
14 | * modification, are permitted provided that the following conditions | ||
15 | * are met: | ||
16 | * 1. Redistributions of source code must retain the above copyright | ||
17 | * notices, this list of conditions and the following disclaimer. | ||
18 | * 2. Redistributions in binary form must reproduce the above copyright | ||
19 | * notices, this list of conditions and the following disclaimer in the | ||
20 | * documentation and/or other materials provided with the distribution. | ||
21 | * 3. All advertising materials mentioning features or use of this software | ||
22 | * must display the following acknowledgement: | ||
23 | * This product includes software developed by Softweyr LLC, the | ||
24 | * University of California, Berkeley, and its contributors. | ||
25 | * 4. Neither the name of the University nor the names of its contributors | ||
26 | * may be used to endorse or promote products derived from this software | ||
27 | * without specific prior written permission. | ||
28 | * | ||
29 | * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS | ||
30 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
32 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE | ||
33 | * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
34 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
35 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
40 | * | ||
41 | * Original version ID: | ||
42 | * FreeBSD: src/lib/libc/string/wcstok.c,v 1.1 2002/09/07 08:16:57 tjr Exp | ||
43 | */ | ||
44 | |||
45 | #if defined(LIBC_SCCS) && !defined(lint) | ||
46 | static char *rcsid = "$OpenBSD: wcstok.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
47 | #endif /* LIBC_SCCS and not lint */ | ||
48 | |||
49 | #include <wchar.h> | ||
50 | |||
51 | wchar_t * | ||
52 | wcstok(s, delim, last) | ||
53 | wchar_t * __restrict s; | ||
54 | const wchar_t * __restrict delim; | ||
55 | wchar_t ** __restrict last; | ||
56 | { | ||
57 | const wchar_t *spanp; | ||
58 | wchar_t c, sc; | ||
59 | wchar_t *tok; | ||
60 | |||
61 | if (s == NULL && (s = *last) == NULL) | ||
62 | return (NULL); | ||
63 | |||
64 | /* | ||
65 | * Skip (span) leading delimiters (s += wcsspn(s, delim), sort of). | ||
66 | */ | ||
67 | cont: | ||
68 | c = *s++; | ||
69 | for (spanp = delim; (sc = *spanp++) != L'\0';) { | ||
70 | if (c == sc) | ||
71 | goto cont; | ||
72 | } | ||
73 | |||
74 | if (c == L'\0') { /* no non-delimiter characters */ | ||
75 | *last = NULL; | ||
76 | return (NULL); | ||
77 | } | ||
78 | tok = s - 1; | ||
79 | |||
80 | /* | ||
81 | * Scan token (scan for delimiters: s += wcscspn(s, delim), sort of). | ||
82 | * Note that delim must have one NUL; we stop if we see that, too. | ||
83 | */ | ||
84 | for (;;) { | ||
85 | c = *s++; | ||
86 | spanp = delim; | ||
87 | do { | ||
88 | if ((sc = *spanp++) == c) { | ||
89 | if (c == L'\0') | ||
90 | s = NULL; | ||
91 | else | ||
92 | s[-1] = L'\0'; | ||
93 | *last = s; | ||
94 | return (tok); | ||
95 | } | ||
96 | } while (sc != L'\0'); | ||
97 | } | ||
98 | /* NOTREACHED */ | ||
99 | } | ||
diff --git a/src/lib/libc/string/wcswcs.c b/src/lib/libc/string/wcswcs.c new file mode 100644 index 0000000000..bd35605547 --- /dev/null +++ b/src/lib/libc/string/wcswcs.c | |||
@@ -0,0 +1,5 @@ | |||
1 | /* $OpenBSD: wcswcs.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcswcs.c,v 1.1 2003/03/05 20:18:17 tshiozak Exp $ */ | ||
3 | |||
4 | #define WCSWCS | ||
5 | #include "wcsstr.c" | ||
diff --git a/src/lib/libc/string/wcswidth.c b/src/lib/libc/string/wcswidth.c new file mode 100644 index 0000000000..c55d9ae72a --- /dev/null +++ b/src/lib/libc/string/wcswidth.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* $OpenBSD: wcswidth.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcswidth.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wcswidth.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | int | ||
39 | wcswidth(s, n) | ||
40 | const wchar_t *s; | ||
41 | size_t n; | ||
42 | { | ||
43 | int w; | ||
44 | |||
45 | w = 0; | ||
46 | while (n && *s) { | ||
47 | w += wcwidth(*s); | ||
48 | s++; | ||
49 | n--; | ||
50 | } | ||
51 | |||
52 | return w; | ||
53 | } | ||
diff --git a/src/lib/libc/string/wmemchr.3 b/src/lib/libc/string/wmemchr.3 new file mode 100644 index 0000000000..3fcf5db0ae --- /dev/null +++ b/src/lib/libc/string/wmemchr.3 | |||
@@ -0,0 +1,141 @@ | |||
1 | .\" $NetBSD: wmemchr.3,v 1.9 2003/09/08 17:54:33 wiz Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" This code is derived from software contributed to Berkeley by | ||
7 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information Processing Systems. | ||
9 | .\" | ||
10 | .\" Redistribution and use in source and binary forms, with or without | ||
11 | .\" modification, are permitted provided that the following conditions | ||
12 | .\" are met: | ||
13 | .\" 1. Redistributions of source code must retain the above copyright | ||
14 | .\" notice, this list of conditions and the following disclaimer. | ||
15 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
16 | .\" notice, this list of conditions and the following disclaimer in the | ||
17 | .\" documentation and/or other materials provided with the distribution. | ||
18 | .\" 3. Neither the name of the University nor the names of its contributors | ||
19 | .\" may be used to endorse or promote products derived from this software | ||
20 | .\" without specific prior written permission. | ||
21 | .\" | ||
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
32 | .\" SUCH DAMAGE. | ||
33 | .\" | ||
34 | .\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93 | ||
35 | .\" | ||
36 | .Dd December 22, 2000 | ||
37 | .Dt WMEMCHR 3 | ||
38 | .Os | ||
39 | .Sh NAME | ||
40 | .Nm wmemchr , | ||
41 | .Nm wmemcmp , | ||
42 | .Nm wmemcpy , | ||
43 | .Nm wmemmove , | ||
44 | .Nm wmemset , | ||
45 | .Nm wcscat , | ||
46 | .Nm wcschr , | ||
47 | .Nm wcscmp , | ||
48 | .Nm wcscpy , | ||
49 | .Nm wcscspn , | ||
50 | .Nm wcslcat , | ||
51 | .Nm wcslcpy , | ||
52 | .Nm wcslen , | ||
53 | .Nm wcsncat , | ||
54 | .Nm wcsncmp , | ||
55 | .Nm wcsncpy , | ||
56 | .Nm wcspbrk , | ||
57 | .Nm wcsrchr , | ||
58 | .Nm wcsspn , | ||
59 | .Nm wcsstr | ||
60 | .Nd wide character string manipulation operations | ||
61 | .Sh LIBRARY | ||
62 | .Lb libc | ||
63 | .Sh SYNOPSIS | ||
64 | .In wchar.h | ||
65 | .Ft wchar_t * | ||
66 | .Fn wmemchr "const wchar_t *s" "wchar_t c" "size_t n" | ||
67 | .Ft int | ||
68 | .Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t n" | ||
69 | .Ft wchar_t * | ||
70 | .Fn wmemcpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" | ||
71 | .Ft wchar_t * | ||
72 | .Fn wmemmove "wchar_t *s1" "const wchar_t *s2" "size_t n" | ||
73 | .Ft wchar_t * | ||
74 | .Fn wmemset "wchar_t *s" "wchar_t c" "size_t n" | ||
75 | .Ft wchar_t * | ||
76 | .Fn wcscat "wchar_t * restrict s1" "const wchar_t * restrict s2" | ||
77 | .Ft wchar_t * | ||
78 | .Fn wcschr "const wchar_t *s" "wchar_t c" | ||
79 | .Ft int | ||
80 | .Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" | ||
81 | .Ft wchar_t * | ||
82 | .Fn wcscpy "wchar_t * restrict s1" "const wchar_t * restrict s2" | ||
83 | .Ft size_t | ||
84 | .Fn wcscspn "const wchar_t *s1" "const wchar_t *s2" | ||
85 | .Ft size_t | ||
86 | .Fn wcslcat "wchar_t *s1" "const wchar_t *s2" "size_t n" | ||
87 | .Ft size_t | ||
88 | .Fn wcslcpy "wchar_t *s1" "const wchar_t *s2" "size_t n" | ||
89 | .Ft size_t | ||
90 | .Fn wcslen "const wchar_t *s" | ||
91 | .Ft wchar_t * | ||
92 | .Fn wcsncat "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" | ||
93 | .Ft int | ||
94 | .Fn wcsncmp "const wchar_t *s1" "const wchar_t * s2" "size_t n" | ||
95 | .Ft wchar_t * | ||
96 | .Fn wcsncpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" | ||
97 | .Ft wchar_t * | ||
98 | .Fn wcspbrk "const wchar_t *s1" "const wchar_t *s2" | ||
99 | .Ft wchar_t * | ||
100 | .Fn wcsrchr "const wchar_t *s" "wchar_t c" | ||
101 | .Ft size_t | ||
102 | .Fn wcsspn "const wchar_t *s1" "const wchar_t *s2" | ||
103 | .Ft wchar_t * | ||
104 | .Fn wcsstr "const wchar_t *s1" "const wchar_t *s2" | ||
105 | .Sh DESCRIPTION | ||
106 | The functions implement string manipulation operations over wide character | ||
107 | strings. | ||
108 | For a detailed description, refer to documents for the respective single-byte | ||
109 | counterpart, such as | ||
110 | .Xr memchr 3 . | ||
111 | .Sh SEE ALSO | ||
112 | .Xr memchr 3 , | ||
113 | .Xr memcmp 3 , | ||
114 | .Xr memcpy 3 , | ||
115 | .Xr memmove 3 , | ||
116 | .Xr memset 3 , | ||
117 | .Xr strcat 3 , | ||
118 | .Xr strchr 3 , | ||
119 | .Xr strcmp 3 , | ||
120 | .Xr strcpy 3 , | ||
121 | .Xr strcspn 3 , | ||
122 | .Xr strlcat 3 , | ||
123 | .Xr strlcpy 3 , | ||
124 | .Xr strlen 3 , | ||
125 | .Xr strncat 3 , | ||
126 | .Xr strncmp 3 , | ||
127 | .Xr strncpy 3 , | ||
128 | .Xr strpbrk 3 , | ||
129 | .Xr strrchr 3 , | ||
130 | .Xr strspn 3 , | ||
131 | .Xr strstr 3 | ||
132 | .Sh STANDARDS | ||
133 | These functions conform to | ||
134 | .St -isoC-99 | ||
135 | and were first introduced in | ||
136 | .St -isoC-amd1 , | ||
137 | with the exception of | ||
138 | .Fn wcslcat | ||
139 | and | ||
140 | .Fn wcslcpy , | ||
141 | which are extensions. | ||
diff --git a/src/lib/libc/string/wmemchr.c b/src/lib/libc/string/wmemchr.c new file mode 100644 index 0000000000..0e50205863 --- /dev/null +++ b/src/lib/libc/string/wmemchr.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* $OpenBSD: wmemchr.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wmemchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wmemchr.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wmemchr(s, c, n) | ||
40 | const wchar_t *s; | ||
41 | wchar_t c; | ||
42 | size_t n; | ||
43 | { | ||
44 | size_t i; | ||
45 | |||
46 | for (i = 0; i < n; i++) { | ||
47 | if (*s == c) { | ||
48 | /* LINTED const castaway */ | ||
49 | return (wchar_t *)s; | ||
50 | } | ||
51 | s++; | ||
52 | } | ||
53 | return NULL; | ||
54 | } | ||
diff --git a/src/lib/libc/string/wmemcmp.c b/src/lib/libc/string/wmemcmp.c new file mode 100644 index 0000000000..4792a3b456 --- /dev/null +++ b/src/lib/libc/string/wmemcmp.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /* $OpenBSD: wmemcmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wmemcmp.c,v 1.3 2003/04/06 18:33:23 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wmemcmp.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | #include "locale/runetype.h" | ||
38 | |||
39 | int | ||
40 | wmemcmp(s1, s2, n) | ||
41 | const wchar_t *s1; | ||
42 | const wchar_t *s2; | ||
43 | size_t n; | ||
44 | { | ||
45 | size_t i; | ||
46 | |||
47 | for (i = 0; i < n; i++) { | ||
48 | if (*s1 != *s2) { | ||
49 | /* wchar might be unsigned */ | ||
50 | return *(const __nbrune_t *)s1 > | ||
51 | *(const __nbrune_t *)s2 ? 1 : -1; | ||
52 | } | ||
53 | s1++; | ||
54 | s2++; | ||
55 | } | ||
56 | return 0; | ||
57 | } | ||
diff --git a/src/lib/libc/string/wmemcpy.c b/src/lib/libc/string/wmemcpy.c new file mode 100644 index 0000000000..628795ce41 --- /dev/null +++ b/src/lib/libc/string/wmemcpy.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* $OpenBSD: wmemcpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wmemcpy.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <string.h> | ||
37 | #include <wchar.h> | ||
38 | |||
39 | wchar_t * | ||
40 | wmemcpy(d, s, n) | ||
41 | wchar_t *d; | ||
42 | const wchar_t *s; | ||
43 | size_t n; | ||
44 | { | ||
45 | |||
46 | return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); | ||
47 | } | ||
diff --git a/src/lib/libc/string/wmemmove.c b/src/lib/libc/string/wmemmove.c new file mode 100644 index 0000000000..e5a0a1fe25 --- /dev/null +++ b/src/lib/libc/string/wmemmove.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* $OpenBSD: wmemmove.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wmemmove.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <string.h> | ||
37 | #include <wchar.h> | ||
38 | |||
39 | wchar_t * | ||
40 | wmemmove(d, s, n) | ||
41 | wchar_t *d; | ||
42 | const wchar_t *s; | ||
43 | size_t n; | ||
44 | { | ||
45 | |||
46 | return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); | ||
47 | } | ||
diff --git a/src/lib/libc/string/wmemset.c b/src/lib/libc/string/wmemset.c new file mode 100644 index 0000000000..abcbe44c46 --- /dev/null +++ b/src/lib/libc/string/wmemset.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* $OpenBSD: wmemset.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #if defined(LIBC_SCCS) && !defined(lint) | ||
33 | static char *rcsid = "$OpenBSD: wmemset.c,v 1.1 2005/04/13 16:35:58 espie Exp $"; | ||
34 | #endif /* LIBC_SCCS and not lint */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | |||
38 | wchar_t * | ||
39 | wmemset(s, c, n) | ||
40 | wchar_t *s; | ||
41 | wchar_t c; | ||
42 | size_t n; | ||
43 | { | ||
44 | size_t i; | ||
45 | wchar_t *p; | ||
46 | |||
47 | p = (wchar_t *)s; | ||
48 | for (i = 0; i < n; i++) { | ||
49 | *p = c; | ||
50 | p++; | ||
51 | } | ||
52 | return s; | ||
53 | } | ||