Debian Codegraph @

terps/tads/tads3/wc_patch/wchar.c

raw symbols SCIP
1 /*
2 Name
3 wchar.c - Wide-character functions.
4 Function
5 Provide definitions of wcscpy and wcslen (wide-character copy
6 and len functions) for systems that don't have them in the standard
7 library.
8 Notes
9
10 Modified
11 09/03/00 MJRoberts - Creation
12 */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16
17 #include "wchar.h"
18
19 /*
20 * wcscpy - this is simply a wide character version of strcpy
21 */
22 wchar_t *wcscpy(wchar_t *dst, const wchar_t *src)
23 {
24 wchar_t *ret;
25
26 /* save the destination pointer as the return value */
27 ret = dst;
28
29 /* copy characters from src to dst until we reach a null */
30 for ( ; *src != L'\0' ; *dst++ = *src++) ;
31
32 /* add the terminating null to the output string */
33 *dst = L'\0';
34
35 /* return the original output buffer pointer */
36 return ret;
37 }
38
39 /*
40 * wcslen - this is a wide character version of strlen
41 */
42 size_t wcslen(const wchar_t *wstr)
43 {
44 size_t cnt;
45
46 /* count the characters until we encounter a null */
47 for (cnt = 0 ; *wstr != L'\0' ; ++cnt, ++wstr) ;
48
49 /* return the number of characters we counted */
50 return cnt;
51 }
52